Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5880)

Unified Diff: chrome/common/mac/app_mode_chrome_locator_unittest.mm

Issue 501303002: [Mac] Make app shims load the same framework version as the running Chrome process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/mac/app_mode_chrome_locator_unittest.mm
diff --git a/chrome/common/mac/app_mode_chrome_locator_unittest.mm b/chrome/common/mac/app_mode_chrome_locator_unittest.mm
index ecaed7d513aee3adf1b94c1ae58e20942acc707c..15808cd4e9a794055cbd07ff188bf0498c276058 100644
--- a/chrome/common/mac/app_mode_chrome_locator_unittest.mm
+++ b/chrome/common/mac/app_mode_chrome_locator_unittest.mm
@@ -11,6 +11,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_version_info.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -44,28 +45,93 @@ TEST(ChromeLocatorTest, GetNonExistentBundleInfo) {
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath executable_path;
- base::string16 raw_version;
base::FilePath version_path;
base::FilePath framework_path;
EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(),
- &executable_path, &raw_version, &version_path, &framework_path));
+ std::string(),
+ &executable_path,
+ &version_path,
+ &framework_path));
}
TEST(ChromeLocatorTest, GetChromeBundleInfo) {
- using app_mode::GetChromeBundleInfo;
+ base::FilePath chrome_bundle_path;
+ GetChromeBundlePath(&chrome_bundle_path);
+ ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
+ base::FilePath executable_path;
+ base::FilePath version_path;
+ base::FilePath framework_path;
+ EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
+ std::string(),
+ &executable_path,
+ &version_path,
+ &framework_path));
+ EXPECT_TRUE(base::PathExists(executable_path));
+ EXPECT_TRUE(base::DirectoryExists(version_path));
+ EXPECT_TRUE(base::PathExists(framework_path));
+}
+
+TEST(ChromeLocatorTest, GetChromeBundleInfoWithLatestVersion) {
base::FilePath chrome_bundle_path;
GetChromeBundlePath(&chrome_bundle_path);
ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
base::FilePath executable_path;
- base::string16 raw_version;
base::FilePath version_path;
base::FilePath framework_path;
- EXPECT_TRUE(GetChromeBundleInfo(chrome_bundle_path,
- &executable_path, &raw_version, &version_path, &framework_path));
+ EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
+ chrome::VersionInfo().Version(),
+ &executable_path,
+ &version_path,
+ &framework_path));
EXPECT_TRUE(base::PathExists(executable_path));
- EXPECT_GT(raw_version.size(), 0U);
EXPECT_TRUE(base::DirectoryExists(version_path));
EXPECT_TRUE(base::PathExists(framework_path));
}
+
+TEST(ChromeLocatorTest, GetChromeBundleInfoWithInvalidVersion) {
+ base::FilePath chrome_bundle_path;
+ GetChromeBundlePath(&chrome_bundle_path);
+ ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
+
+ base::FilePath executable_path;
+ base::FilePath version_path;
+ base::FilePath framework_path;
+ // This still passes because it should default to the latest version.
+ EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
+ std::string("invalid_version"),
+ &executable_path,
+ &version_path,
+ &framework_path));
+ EXPECT_TRUE(base::PathExists(executable_path));
+ EXPECT_TRUE(base::DirectoryExists(version_path));
+ EXPECT_TRUE(base::PathExists(framework_path));
+}
+
+TEST(ChromeLocatorTest, GetChromeBundleInfoWithPreviousVersion) {
+ base::FilePath chrome_bundle_path;
+ GetChromeBundlePath(&chrome_bundle_path);
+ ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
+
+ // Make a symlink that pretends to be a previous version.
+ base::FilePath fake_version_directory = chrome_bundle_path.Append("Contents")
+ .Append("Versions")
+ .Append("previous_version");
+ EXPECT_TRUE(base::CreateSymbolicLink(
+ base::FilePath(chrome::VersionInfo().Version()), fake_version_directory));
+
+ base::FilePath executable_path;
+ base::FilePath version_path;
+ base::FilePath framework_path;
+ EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
+ std::string("previous_version"),
+ &executable_path,
+ &version_path,
+ &framework_path));
+ EXPECT_TRUE(base::PathExists(executable_path));
+ EXPECT_TRUE(base::DirectoryExists(version_path));
+ EXPECT_TRUE(base::PathExists(framework_path));
+
+ base::DeleteFile(fake_version_directory, false);
+}

Powered by Google App Engine
This is Rietveld 408576698