Update platformDir search in tests. [DO NOT MERGE]

When trying to find the SDK Platform Dir for LayoutLib tests, also
test if the dir from which the tests are run is module dir.

Change-Id: Id5c6038d07ebbb122e38f907ad488ed1f2bcde32
(cherry picked from commit 612a05e7e1)
This commit is contained in:
Deepanshu Gupta
2015-05-20 11:28:50 -07:00
parent afedbc47b3
commit d7e89906a4

View File

@@ -124,9 +124,14 @@ public class Main {
if (platformDir != null) { if (platformDir != null) {
return platformDir; return platformDir;
} }
// Test if workingDir is platform/frameworks/base/tools/layoutlib. That is, root should be
// workingDir/../../../../ (4 levels up) // Test if workingDir is platform/frameworks/base/tools/layoutlib/bridge.
File currentDir = workingDir; File currentDir = workingDir;
if (currentDir.getName().equalsIgnoreCase("bridge")) {
currentDir = currentDir.getParentFile();
}
// Test if currentDir is platform/frameworks/base/tools/layoutlib. That is, root should be
// workingDir/../../../../ (4 levels up)
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (currentDir != null) { if (currentDir != null) {
currentDir = currentDir.getParentFile(); currentDir = currentDir.getParentFile();