1 // Copyright 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "android/avd/util.h" 16 #include "android/utils/path.h" 17 #include "android/base/testing/TestSystem.h" 18 19 #include <gtest/gtest.h> 20 21 using namespace android::base; 22 TEST(AvdUtilWrapper,emulator_path_getSdkRoot)23TEST(AvdUtilWrapper, emulator_path_getSdkRoot) { 24 TestSystem sys("", 32, "/myhome"); 25 ASSERT_TRUE(sys.getTempRoot()->makeSubDir("/tmp")); 26 ASSERT_TRUE(sys.getTempRoot()->makeSubDir("/tmp/Sdk")); 27 ASSERT_TRUE(sys.getTempRoot()->makeSubDir("/tmp/Sdk/platform-tools")); 28 ASSERT_TRUE(sys.getTempRoot()->makeSubDir("/tmp/Sdk/platforms")); 29 ASSERT_TRUE(sys.getTempRoot()->makeSubDir("/tmp/Sdk/tools")); 30 ASSERT_TRUE(sys.pathIsDir("/tmp/Sdk")); 31 32 sys.setLauncherDirectory("."); 33 sys.setCurrentDirectory("/tmp/Sdk/tools"); 34 35 char* sdk = path_getSdkRoot(); 36 EXPECT_TRUE(sdk != nullptr); 37 EXPECT_TRUE(path_is_absolute(sdk)); 38 free(sdk); 39 } 40 41 42