| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/common/mac/app_mode_chrome_locator.h" |
| 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 |
| 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" |
| 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 namespace { |
| 16 |
| 17 // Return the path to the Chrome/Chromium app bundle compiled along with the |
| 18 // test executable. |
| 19 void GetChromeBundlePath(FilePath* chrome_bundle) { |
| 20 FilePath path; |
| 21 PathService::Get(base::DIR_EXE, &path); |
| 22 path = path.Append(chrome::kBrowserProcessExecutableNameChromium); |
| 23 path = path.ReplaceExtension(FilePath::StringType("app")); |
| 24 *chrome_bundle = path; |
| 25 } |
| 26 |
| 27 } // namespace |
| 28 |
| 29 TEST(ChromeLocatorTest, FindBundle) { |
| 30 FilePath finder_bundle_path; |
| 31 EXPECT_TRUE( |
| 32 app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path)); |
| 33 EXPECT_TRUE(file_util::DirectoryExists(finder_bundle_path)); |
| 34 } |
| 35 |
| 36 TEST(ChromeLocatorTest, FindNonExistentBundle) { |
| 37 FilePath dummy; |
| 38 EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy)); |
| 39 } |
| 40 |
| 41 TEST(ChromeLocatorTest, GetNonExistentBundleInfo) { |
| 42 FilePath temp_dir; |
| 43 ASSERT_TRUE(file_util::CreateNewTempDirectory("", &temp_dir)); |
| 44 file_util::ScopedDirectory cleanup(&temp_dir); |
| 45 |
| 46 string16 raw_version; |
| 47 FilePath version_path; |
| 48 FilePath framework_path; |
| 49 EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir, |
| 50 &raw_version, &version_path, &framework_path)); |
| 51 } |
| 52 |
| 53 TEST(ChromeLocatorTest, GetChromeBundleInfo) { |
| 54 using app_mode::GetChromeBundleInfo; |
| 55 |
| 56 FilePath chrome_bundle_path; |
| 57 GetChromeBundlePath(&chrome_bundle_path); |
| 58 ASSERT_TRUE(file_util::DirectoryExists(chrome_bundle_path)); |
| 59 |
| 60 string16 raw_version; |
| 61 FilePath version_path; |
| 62 FilePath framework_path; |
| 63 EXPECT_TRUE(GetChromeBundleInfo(chrome_bundle_path, |
| 64 &raw_version, &version_path, &framework_path)); |
| 65 EXPECT_GT(raw_version.size(), 0U); |
| 66 EXPECT_TRUE(file_util::DirectoryExists(version_path)); |
| 67 EXPECT_TRUE(file_util::PathExists(framework_path)); |
| 68 } |
| OLD | NEW |