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

Side by Side Diff: apps/app_shim/app_shim_host_manager_browsertest_mac.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
« no previous file with comments | « apps/app_shim/DEPS ('k') | apps/app_shim/app_shim_host_manager_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "apps/app_shim/app_shim_host_manager_mac.h" 5 #include "apps/app_shim/app_shim_host_manager_mac.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "apps/app_shim/app_shim_messages.h" 9 #include "apps/app_shim/app_shim_messages.h"
10 #include "apps/app_shim/test/app_shim_host_manager_test_api_mac.h" 10 #include "apps/app_shim/test/app_shim_host_manager_test_api_mac.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_version_info.h"
18 #include "chrome/common/mac/app_mode_common.h" 19 #include "chrome/common/mac/app_mode_common.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
20 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
21 #include "ipc/ipc_channel_proxy.h" 22 #include "ipc/ipc_channel_proxy.h"
22 #include "ipc/ipc_listener.h" 23 #include "ipc/ipc_listener.h"
23 #include "ipc/ipc_message.h" 24 #include "ipc/ipc_message.h"
24 25
25 namespace { 26 namespace {
26 27
27 const char kTestAppMode[] = "test_app"; 28 const char kTestAppMode[] = "test_app";
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 220
220 // Tests for the files created by AppShimHostManager. 221 // Tests for the files created by AppShimHostManager.
221 class AppShimHostManagerBrowserTestSocketFiles 222 class AppShimHostManagerBrowserTestSocketFiles
222 : public AppShimHostManagerBrowserTest { 223 : public AppShimHostManagerBrowserTest {
223 public: 224 public:
224 AppShimHostManagerBrowserTestSocketFiles() {} 225 AppShimHostManagerBrowserTestSocketFiles() {}
225 226
226 protected: 227 protected:
227 base::FilePath directory_in_tmp_; 228 base::FilePath directory_in_tmp_;
228 base::FilePath symlink_path_; 229 base::FilePath symlink_path_;
230 base::FilePath version_path_;
229 231
230 private: 232 private:
231 virtual bool SetUpUserDataDirectory() OVERRIDE; 233 virtual bool SetUpUserDataDirectory() OVERRIDE;
232 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; 234 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE;
233 235
234 DISALLOW_COPY_AND_ASSIGN(AppShimHostManagerBrowserTestSocketFiles); 236 DISALLOW_COPY_AND_ASSIGN(AppShimHostManagerBrowserTestSocketFiles);
235 }; 237 };
236 238
237 bool AppShimHostManagerBrowserTestSocketFiles::SetUpUserDataDirectory() { 239 bool AppShimHostManagerBrowserTestSocketFiles::SetUpUserDataDirectory() {
238 // Create an existing symlink. It should be replaced by AppShimHostManager. 240 // Create an existing symlink. It should be replaced by AppShimHostManager.
239 base::FilePath user_data_dir; 241 base::FilePath user_data_dir;
240 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); 242 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
241 symlink_path_ = user_data_dir.Append(app_mode::kAppShimSocketSymlinkName); 243 symlink_path_ = user_data_dir.Append(app_mode::kAppShimSocketSymlinkName);
242 base::FilePath temp_dir; 244 base::FilePath temp_dir;
243 PathService::Get(base::DIR_TEMP, &temp_dir); 245 PathService::Get(base::DIR_TEMP, &temp_dir);
244 EXPECT_TRUE(base::CreateSymbolicLink(temp_dir.Append("chrome-XXXXXX"), 246 EXPECT_TRUE(base::CreateSymbolicLink(temp_dir.Append("chrome-XXXXXX"),
245 symlink_path_)); 247 symlink_path_));
248
249 // Create an invalid RunningChromeVersion file.
250 version_path_ =
251 user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName);
252 EXPECT_TRUE(base::CreateSymbolicLink(base::FilePath("invalid_version"),
253 version_path_));
246 return AppShimHostManagerBrowserTest::SetUpUserDataDirectory(); 254 return AppShimHostManagerBrowserTest::SetUpUserDataDirectory();
247 } 255 }
248 256
249 void AppShimHostManagerBrowserTestSocketFiles:: 257 void AppShimHostManagerBrowserTestSocketFiles::
250 TearDownInProcessBrowserTestFixture() { 258 TearDownInProcessBrowserTestFixture() {
251 // Check that created files have been deleted. 259 // Check that created files have been deleted.
252 EXPECT_FALSE(base::PathExists(directory_in_tmp_)); 260 EXPECT_FALSE(base::PathExists(directory_in_tmp_));
253 EXPECT_FALSE(base::PathExists(symlink_path_)); 261 EXPECT_FALSE(base::PathExists(symlink_path_));
262 EXPECT_FALSE(base::PathExists(version_path_));
254 } 263 }
255 264
256 IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSocketFiles, 265 IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSocketFiles,
257 ReplacesSymlinkAndCleansUpFiles) { 266 ReplacesSymlinkAndCleansUpFiles) {
258 // Get the directory created by AppShimHostManager. 267 // Get the directory created by AppShimHostManager.
259 test::AppShimHostManagerTestApi test_api( 268 test::AppShimHostManagerTestApi test_api(
260 g_browser_process->platform_part()->app_shim_host_manager()); 269 g_browser_process->platform_part()->app_shim_host_manager());
261 directory_in_tmp_ = test_api.directory_in_tmp(); 270 directory_in_tmp_ = test_api.directory_in_tmp();
262 271
263 // Check that socket files have been created. 272 // Check that socket files have been created.
264 EXPECT_TRUE(base::PathExists(directory_in_tmp_)); 273 EXPECT_TRUE(base::PathExists(directory_in_tmp_));
265 EXPECT_TRUE(base::PathExists(symlink_path_)); 274 EXPECT_TRUE(base::PathExists(symlink_path_));
266 275
267 // Check that the symlink has been replaced. 276 // Check that the symlink has been replaced.
268 base::FilePath socket_path; 277 base::FilePath socket_path;
269 ASSERT_TRUE(base::ReadSymbolicLink(symlink_path_, &socket_path)); 278 ASSERT_TRUE(base::ReadSymbolicLink(symlink_path_, &socket_path));
270 EXPECT_EQ(app_mode::kAppShimSocketShortName, socket_path.BaseName().value()); 279 EXPECT_EQ(app_mode::kAppShimSocketShortName, socket_path.BaseName().value());
280
281 // Check that the RunningChromeVersion file is correctly written.
282 base::FilePath version;
283 EXPECT_TRUE(base::ReadSymbolicLink(version_path_, &version));
284 EXPECT_EQ(chrome::VersionInfo().Version(), version.value());
271 } 285 }
272 286
273 } // namespace 287 } // namespace
OLDNEW
« no previous file with comments | « apps/app_shim/DEPS ('k') | apps/app_shim/app_shim_host_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698