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

Side by Side Diff: chrome/common/mac/app_mode_chrome_locator_browsertest.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: Sync and rebase Created 6 years, 3 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 unified diff | Download patch
OLDNEW
(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/files/file_path.h"
10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h"
12 #include "base/path_service.h"
13 #include "chrome/common/chrome_constants.h"
14 #include "chrome/common/chrome_version_info.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace {
18
19 // This needs to be a browser test because it expects to find a Chrome.app
20 // bundle in the output directory.
21
22 // Return the path to the Chrome/Chromium app bundle compiled along with the
23 // test executable.
24 void GetChromeBundlePath(base::FilePath* chrome_bundle) {
25 base::FilePath path;
26 PathService::Get(base::DIR_MODULE, &path);
27 path = path.Append(chrome::kBrowserProcessExecutableNameChromium);
28 path = path.ReplaceExtension(base::FilePath::StringType("app"));
29 *chrome_bundle = path;
30 }
31
32 } // namespace
33
34 TEST(ChromeLocatorTest, FindBundle) {
35 base::FilePath finder_bundle_path;
36 EXPECT_TRUE(
37 app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path));
38 EXPECT_TRUE(base::DirectoryExists(finder_bundle_path));
39 }
40
41 TEST(ChromeLocatorTest, FindNonExistentBundle) {
42 base::FilePath dummy;
43 EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy));
44 }
45
46 TEST(ChromeLocatorTest, GetNonExistentBundleInfo) {
47 base::ScopedTempDir temp_dir;
48 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
49
50 base::FilePath executable_path;
51 base::FilePath version_path;
52 base::FilePath framework_path;
53 EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(),
54 std::string(),
55 &executable_path,
56 &version_path,
57 &framework_path));
58 }
59
60 TEST(ChromeLocatorTest, GetChromeBundleInfo) {
61 base::FilePath chrome_bundle_path;
62 GetChromeBundlePath(&chrome_bundle_path);
63 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
64
65 base::FilePath executable_path;
66 base::FilePath version_path;
67 base::FilePath framework_path;
68 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
69 std::string(),
70 &executable_path,
71 &version_path,
72 &framework_path));
73 EXPECT_TRUE(base::PathExists(executable_path));
74 EXPECT_TRUE(base::DirectoryExists(version_path));
75 EXPECT_TRUE(base::PathExists(framework_path));
76 }
77
78 TEST(ChromeLocatorTest, GetChromeBundleInfoWithLatestVersion) {
79 base::FilePath chrome_bundle_path;
80 GetChromeBundlePath(&chrome_bundle_path);
81 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
82
83 base::FilePath executable_path;
84 base::FilePath version_path;
85 base::FilePath framework_path;
86 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
87 chrome::VersionInfo().Version(),
88 &executable_path,
89 &version_path,
90 &framework_path));
91 EXPECT_TRUE(base::PathExists(executable_path));
92 EXPECT_TRUE(base::DirectoryExists(version_path));
93 EXPECT_TRUE(base::PathExists(framework_path));
94 }
95
96 TEST(ChromeLocatorTest, GetChromeBundleInfoWithInvalidVersion) {
97 base::FilePath chrome_bundle_path;
98 GetChromeBundlePath(&chrome_bundle_path);
99 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
100
101 base::FilePath executable_path;
102 base::FilePath version_path;
103 base::FilePath framework_path;
104 // This still passes because it should default to the latest version.
105 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
106 std::string("invalid_version"),
107 &executable_path,
108 &version_path,
109 &framework_path));
110 EXPECT_TRUE(base::PathExists(executable_path));
111 EXPECT_TRUE(base::DirectoryExists(version_path));
112 EXPECT_TRUE(base::PathExists(framework_path));
113 }
114
115 TEST(ChromeLocatorTest, GetChromeBundleInfoWithPreviousVersion) {
116 base::FilePath chrome_bundle_path;
117 GetChromeBundlePath(&chrome_bundle_path);
118 ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
119
120 // Make a symlink that pretends to be a previous version.
121 base::FilePath fake_version_directory = chrome_bundle_path.Append("Contents")
122 .Append("Versions")
123 .Append("previous_version");
124 EXPECT_TRUE(base::CreateSymbolicLink(
125 base::FilePath(chrome::VersionInfo().Version()), fake_version_directory));
126
127 base::FilePath executable_path;
128 base::FilePath version_path;
129 base::FilePath framework_path;
130 EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path,
131 std::string("previous_version"),
132 &executable_path,
133 &version_path,
134 &framework_path));
135 EXPECT_TRUE(base::PathExists(executable_path));
136 EXPECT_TRUE(base::DirectoryExists(version_path));
137 EXPECT_TRUE(base::PathExists(framework_path));
138
139 base::DeleteFile(fake_version_directory, false);
140 }
OLDNEW
« no previous file with comments | « chrome/common/mac/app_mode_chrome_locator.mm ('k') | chrome/common/mac/app_mode_chrome_locator_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698