| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/common/mac/app_mode_chrome_locator.h" | 5 #import "chrome/common/mac/app_mode_chrome_locator.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 EXPECT_TRUE( | 36 EXPECT_TRUE( |
| 37 app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path)); | 37 app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path)); |
| 38 EXPECT_TRUE(base::DirectoryExists(finder_bundle_path)); | 38 EXPECT_TRUE(base::DirectoryExists(finder_bundle_path)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 TEST(ChromeLocatorTest, FindNonExistentBundle) { | 41 TEST(ChromeLocatorTest, FindNonExistentBundle) { |
| 42 base::FilePath dummy; | 42 base::FilePath dummy; |
| 43 EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy)); | 43 EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 TEST(ChromeLocatorTest, GetNonExistentBundleInfo) { | 46 // GetChromeBundlePath doesn't work on official builds. Disable them until it's |
| 47 // fixed. http://crbug.com/409615 |
| 48 #if defined(OFFICIAL_BUILD) |
| 49 #define MAYBE_GetNonExistentBundleInfo DISABLED_GetNonExistentBundleInfo |
| 50 #define MAYBE_GetChromeBundleInfo DISABLED_GetChromeBundleInfo |
| 51 #define MAYBE_GetChromeBundleInfoWithLatestVersion \ |
| 52 DISABLED_GetChromeBundleInfoWithLatestVersion |
| 53 #define MAYBE_GetChromeBundleInfoWithInvalidVersion \ |
| 54 DISABLED_GetChromeBundleInfoWithInvalidVersion |
| 55 #define MAYBE_GetChromeBundleInfoWithPreviousVersion \ |
| 56 DISABLED_GetChromeBundleInfoWithPreviousVersion |
| 57 #else |
| 58 #define MAYBE_GetNonExistentBundleInfo GetNonExistentBundleInfo |
| 59 #define MAYBE_GetChromeBundleInfo GetChromeBundleInfo |
| 60 #define MAYBE_GetChromeBundleInfoWithLatestVersion \ |
| 61 GetChromeBundleInfoWithLatestVersion |
| 62 #define MAYBE_GetChromeBundleInfoWithInvalidVersion \ |
| 63 GetChromeBundleInfoWithInvalidVersion |
| 64 #define MAYBE_GetChromeBundleInfoWithPreviousVersion \ |
| 65 GetChromeBundleInfoWithPreviousVersion |
| 66 #endif |
| 67 |
| 68 TEST(ChromeLocatorTest, MAYBE_GetNonExistentBundleInfo) { |
| 47 base::ScopedTempDir temp_dir; | 69 base::ScopedTempDir temp_dir; |
| 48 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 70 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 49 | 71 |
| 50 base::FilePath executable_path; | 72 base::FilePath executable_path; |
| 51 base::FilePath version_path; | 73 base::FilePath version_path; |
| 52 base::FilePath framework_path; | 74 base::FilePath framework_path; |
| 53 EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(), | 75 EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(), |
| 54 std::string(), | 76 std::string(), |
| 55 &executable_path, | 77 &executable_path, |
| 56 &version_path, | 78 &version_path, |
| 57 &framework_path)); | 79 &framework_path)); |
| 58 } | 80 } |
| 59 | 81 |
| 60 TEST(ChromeLocatorTest, GetChromeBundleInfo) { | 82 TEST(ChromeLocatorTest, MAYBE_GetChromeBundleInfo) { |
| 61 base::FilePath chrome_bundle_path; | 83 base::FilePath chrome_bundle_path; |
| 62 GetChromeBundlePath(&chrome_bundle_path); | 84 GetChromeBundlePath(&chrome_bundle_path); |
| 63 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); | 85 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); |
| 64 | 86 |
| 65 base::FilePath executable_path; | 87 base::FilePath executable_path; |
| 66 base::FilePath version_path; | 88 base::FilePath version_path; |
| 67 base::FilePath framework_path; | 89 base::FilePath framework_path; |
| 68 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, | 90 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, |
| 69 std::string(), | 91 std::string(), |
| 70 &executable_path, | 92 &executable_path, |
| 71 &version_path, | 93 &version_path, |
| 72 &framework_path)); | 94 &framework_path)); |
| 73 EXPECT_TRUE(base::PathExists(executable_path)); | 95 EXPECT_TRUE(base::PathExists(executable_path)); |
| 74 EXPECT_TRUE(base::DirectoryExists(version_path)); | 96 EXPECT_TRUE(base::DirectoryExists(version_path)); |
| 75 EXPECT_TRUE(base::PathExists(framework_path)); | 97 EXPECT_TRUE(base::PathExists(framework_path)); |
| 76 } | 98 } |
| 77 | 99 |
| 78 TEST(ChromeLocatorTest, GetChromeBundleInfoWithLatestVersion) { | 100 TEST(ChromeLocatorTest, MAYBE_GetChromeBundleInfoWithLatestVersion) { |
| 79 base::FilePath chrome_bundle_path; | 101 base::FilePath chrome_bundle_path; |
| 80 GetChromeBundlePath(&chrome_bundle_path); | 102 GetChromeBundlePath(&chrome_bundle_path); |
| 81 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); | 103 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); |
| 82 | 104 |
| 83 base::FilePath executable_path; | 105 base::FilePath executable_path; |
| 84 base::FilePath version_path; | 106 base::FilePath version_path; |
| 85 base::FilePath framework_path; | 107 base::FilePath framework_path; |
| 86 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, | 108 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, |
| 87 chrome::VersionInfo().Version(), | 109 chrome::VersionInfo().Version(), |
| 88 &executable_path, | 110 &executable_path, |
| 89 &version_path, | 111 &version_path, |
| 90 &framework_path)); | 112 &framework_path)); |
| 91 EXPECT_TRUE(base::PathExists(executable_path)); | 113 EXPECT_TRUE(base::PathExists(executable_path)); |
| 92 EXPECT_TRUE(base::DirectoryExists(version_path)); | 114 EXPECT_TRUE(base::DirectoryExists(version_path)); |
| 93 EXPECT_TRUE(base::PathExists(framework_path)); | 115 EXPECT_TRUE(base::PathExists(framework_path)); |
| 94 } | 116 } |
| 95 | 117 |
| 96 TEST(ChromeLocatorTest, GetChromeBundleInfoWithInvalidVersion) { | 118 TEST(ChromeLocatorTest, MAYBE_GetChromeBundleInfoWithInvalidVersion) { |
| 97 base::FilePath chrome_bundle_path; | 119 base::FilePath chrome_bundle_path; |
| 98 GetChromeBundlePath(&chrome_bundle_path); | 120 GetChromeBundlePath(&chrome_bundle_path); |
| 99 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); | 121 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); |
| 100 | 122 |
| 101 base::FilePath executable_path; | 123 base::FilePath executable_path; |
| 102 base::FilePath version_path; | 124 base::FilePath version_path; |
| 103 base::FilePath framework_path; | 125 base::FilePath framework_path; |
| 104 // This still passes because it should default to the latest version. | 126 // This still passes because it should default to the latest version. |
| 105 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, | 127 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, |
| 106 std::string("invalid_version"), | 128 std::string("invalid_version"), |
| 107 &executable_path, | 129 &executable_path, |
| 108 &version_path, | 130 &version_path, |
| 109 &framework_path)); | 131 &framework_path)); |
| 110 EXPECT_TRUE(base::PathExists(executable_path)); | 132 EXPECT_TRUE(base::PathExists(executable_path)); |
| 111 EXPECT_TRUE(base::DirectoryExists(version_path)); | 133 EXPECT_TRUE(base::DirectoryExists(version_path)); |
| 112 EXPECT_TRUE(base::PathExists(framework_path)); | 134 EXPECT_TRUE(base::PathExists(framework_path)); |
| 113 } | 135 } |
| 114 | 136 |
| 115 TEST(ChromeLocatorTest, GetChromeBundleInfoWithPreviousVersion) { | 137 TEST(ChromeLocatorTest, MAYBE_GetChromeBundleInfoWithPreviousVersion) { |
| 116 base::FilePath chrome_bundle_path; | 138 base::FilePath chrome_bundle_path; |
| 117 GetChromeBundlePath(&chrome_bundle_path); | 139 GetChromeBundlePath(&chrome_bundle_path); |
| 118 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); | 140 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); |
| 119 | 141 |
| 120 // Make a symlink that pretends to be a previous version. | 142 // Make a symlink that pretends to be a previous version. |
| 121 base::FilePath fake_version_directory = chrome_bundle_path.Append("Contents") | 143 base::FilePath fake_version_directory = chrome_bundle_path.Append("Contents") |
| 122 .Append("Versions") | 144 .Append("Versions") |
| 123 .Append("previous_version"); | 145 .Append("previous_version"); |
| 124 EXPECT_TRUE(base::CreateSymbolicLink( | 146 EXPECT_TRUE(base::CreateSymbolicLink( |
| 125 base::FilePath(chrome::VersionInfo().Version()), fake_version_directory)); | 147 base::FilePath(chrome::VersionInfo().Version()), fake_version_directory)); |
| 126 | 148 |
| 127 base::FilePath executable_path; | 149 base::FilePath executable_path; |
| 128 base::FilePath version_path; | 150 base::FilePath version_path; |
| 129 base::FilePath framework_path; | 151 base::FilePath framework_path; |
| 130 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, | 152 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, |
| 131 std::string("previous_version"), | 153 std::string("previous_version"), |
| 132 &executable_path, | 154 &executable_path, |
| 133 &version_path, | 155 &version_path, |
| 134 &framework_path)); | 156 &framework_path)); |
| 135 EXPECT_TRUE(base::PathExists(executable_path)); | 157 EXPECT_TRUE(base::PathExists(executable_path)); |
| 136 EXPECT_TRUE(base::DirectoryExists(version_path)); | 158 EXPECT_TRUE(base::DirectoryExists(version_path)); |
| 137 EXPECT_TRUE(base::PathExists(framework_path)); | 159 EXPECT_TRUE(base::PathExists(framework_path)); |
| 138 | 160 |
| 139 base::DeleteFile(fake_version_directory, false); | 161 base::DeleteFile(fake_version_directory, false); |
| 140 } | 162 } |
| OLD | NEW |