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

Side by Side Diff: chrome/browser/apps/app_shim/app_shim_host_manager_browsertest_mac.mm

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 years, 7 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
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 "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" 5 #include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/threading/thread_restrictions.h"
13 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" 14 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
14 #include "chrome/browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h " 15 #include "chrome/browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h "
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/mac/app_mode_common.h" 20 #include "chrome/common/mac/app_mode_common.h"
20 #include "chrome/common/mac/app_shim_messages.h" 21 #include "chrome/common/mac/app_shim_messages.h"
21 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
22 #include "components/version_info/version_info.h" 23 #include "components/version_info/version_info.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 base::Thread::Options io_thread_options; 59 base::Thread::Options io_thread_options;
59 io_thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 60 io_thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
60 io_thread_.StartWithOptions(io_thread_options); 61 io_thread_.StartWithOptions(io_thread_options);
61 62
62 base::FilePath user_data_dir; 63 base::FilePath user_data_dir;
63 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); 64 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
64 base::FilePath symlink_path = 65 base::FilePath symlink_path =
65 user_data_dir.Append(app_mode::kAppShimSocketSymlinkName); 66 user_data_dir.Append(app_mode::kAppShimSocketSymlinkName);
66 67
67 base::FilePath socket_path; 68 base::FilePath socket_path;
69 base::ThreadRestrictions::ScopedAllowIO allow_io;
68 CHECK(base::ReadSymbolicLink(symlink_path, &socket_path)); 70 CHECK(base::ReadSymbolicLink(symlink_path, &socket_path));
69 app_mode::VerifySocketPermissions(socket_path); 71 app_mode::VerifySocketPermissions(socket_path);
70 72
71 channel_ = IPC::ChannelProxy::Create( 73 channel_ = IPC::ChannelProxy::Create(
72 IPC::ChannelMojo::CreateClientFactory( 74 IPC::ChannelMojo::CreateClientFactory(
73 mojo::edk::ConnectToPeerProcess(mojo::edk::CreateClientHandle( 75 mojo::edk::ConnectToPeerProcess(mojo::edk::CreateClientHandle(
74 mojo::edk::NamedPlatformHandle(socket_path.value()))), 76 mojo::edk::NamedPlatformHandle(socket_path.value()))),
75 io_thread_.task_runner().get()), 77 io_thread_.task_runner().get()),
76 this, io_thread_.task_runner().get()); 78 this, io_thread_.task_runner().get());
77 } 79 }
78 80
79 TestShimClient::~TestShimClient() {} 81 TestShimClient::~TestShimClient() {
82 base::ThreadRestrictions::ScopedAllowIO allow_io;
83 io_thread_.Stop();
84 }
80 85
81 bool TestShimClient::OnMessageReceived(const IPC::Message& message) { 86 bool TestShimClient::OnMessageReceived(const IPC::Message& message) {
82 return true; 87 return true;
83 } 88 }
84 89
85 void TestShimClient::OnChannelError() { 90 void TestShimClient::OnChannelError() {
86 // Client should not get any channel errors for the current set of tests. 91 // Client should not get any channel errors for the current set of tests.
87 PLOG(FATAL) << "ChannelError"; 92 PLOG(FATAL) << "ChannelError";
88 } 93 }
89 94
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 274 }
270 275
271 IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSocketFiles, 276 IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSocketFiles,
272 ReplacesSymlinkAndCleansUpFiles) { 277 ReplacesSymlinkAndCleansUpFiles) {
273 // Get the directory created by AppShimHostManager. 278 // Get the directory created by AppShimHostManager.
274 test::AppShimHostManagerTestApi test_api( 279 test::AppShimHostManagerTestApi test_api(
275 g_browser_process->platform_part()->app_shim_host_manager()); 280 g_browser_process->platform_part()->app_shim_host_manager());
276 directory_in_tmp_ = test_api.directory_in_tmp(); 281 directory_in_tmp_ = test_api.directory_in_tmp();
277 282
278 // Check that socket files have been created. 283 // Check that socket files have been created.
284 base::ThreadRestrictions::ScopedAllowIO allow_io;
279 EXPECT_TRUE(base::PathExists(directory_in_tmp_)); 285 EXPECT_TRUE(base::PathExists(directory_in_tmp_));
280 EXPECT_TRUE(base::PathExists(symlink_path_)); 286 EXPECT_TRUE(base::PathExists(symlink_path_));
281 287
282 // Check that the symlink has been replaced. 288 // Check that the symlink has been replaced.
283 base::FilePath socket_path; 289 base::FilePath socket_path;
284 ASSERT_TRUE(base::ReadSymbolicLink(symlink_path_, &socket_path)); 290 ASSERT_TRUE(base::ReadSymbolicLink(symlink_path_, &socket_path));
285 EXPECT_EQ(app_mode::kAppShimSocketShortName, socket_path.BaseName().value()); 291 EXPECT_EQ(app_mode::kAppShimSocketShortName, socket_path.BaseName().value());
286 292
287 // Check that the RunningChromeVersion file is correctly written. 293 // Check that the RunningChromeVersion file is correctly written.
288 base::FilePath version; 294 base::FilePath version;
289 EXPECT_TRUE(base::ReadSymbolicLink(version_path_, &version)); 295 EXPECT_TRUE(base::ReadSymbolicLink(version_path_, &version));
290 EXPECT_EQ(version_info::GetVersionNumber(), version.value()); 296 EXPECT_EQ(version_info::GetVersionNumber(), version.value());
291 } 297 }
292 298
293 } // namespace 299 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/apps/app_browsertest.cc ('k') | chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698