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

Side by Side Diff: chrome/browser/app_controller_mac_browsertest.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
« no previous file with comments | « base/test/multiprocess_test.cc ('k') | chrome/browser/apps/app_browsertest.cc » ('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 (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 <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 #import <Cocoa/Cocoa.h> 6 #import <Cocoa/Cocoa.h>
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #import <Foundation/NSAppleEventDescriptor.h> 8 #import <Foundation/NSAppleEventDescriptor.h>
9 #import <objc/message.h> 9 #import <objc/message.h>
10 #import <objc/runtime.h> 10 #import <objc/runtime.h>
11 #include <stddef.h> 11 #include <stddef.h>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
15 #include "base/mac/scoped_nsobject.h" 15 #include "base/mac/scoped_nsobject.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/thread_restrictions.h"
19 #include "chrome/app/chrome_command_ids.h" 20 #include "chrome/app/chrome_command_ids.h"
20 #import "chrome/browser/app_controller_mac.h" 21 #import "chrome/browser/app_controller_mac.h"
21 #include "chrome/browser/apps/app_browsertest_util.h" 22 #include "chrome/browser/apps/app_browsertest_util.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/history/history_service_factory.h" 25 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/profiles/profile_attributes_entry.h" 26 #include "chrome/browser/profiles/profile_attributes_entry.h"
26 #include "chrome/browser/profiles/profile_attributes_storage.h" 27 #include "chrome/browser/profiles/profile_attributes_storage.h"
27 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // Test that for a locked last profile, a reopen event opens the User Manager. 251 // Test that for a locked last profile, a reopen event opens the User Manager.
251 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, 252 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest,
252 LockedProfileReopenWithNoWindows) { 253 LockedProfileReopenWithNoWindows) {
253 // The User Manager uses the system profile as its underlying profile. To 254 // The User Manager uses the system profile as its underlying profile. To
254 // minimize flakiness due to the scheduling/descheduling of tasks on the 255 // minimize flakiness due to the scheduling/descheduling of tasks on the
255 // different threads, pre-initialize the guest profile before it is needed. 256 // different threads, pre-initialize the guest profile before it is needed.
256 CreateAndWaitForSystemProfile(); 257 CreateAndWaitForSystemProfile();
257 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); 258 base::scoped_nsobject<AppController> ac([[AppController alloc] init]);
258 259
259 // Lock the active profile. 260 // Lock the active profile.
261 base::ThreadRestrictions::ScopedAllowIO allow_io;
260 Profile* profile = [ac lastProfile]; 262 Profile* profile = [ac lastProfile];
261 ProfileAttributesEntry* entry; 263 ProfileAttributesEntry* entry;
262 ASSERT_TRUE(g_browser_process->profile_manager()-> 264 ASSERT_TRUE(g_browser_process->profile_manager()->
263 GetProfileAttributesStorage(). 265 GetProfileAttributesStorage().
264 GetProfileAttributesWithPath(profile->GetPath(), &entry)); 266 GetProfileAttributesWithPath(profile->GetPath(), &entry));
265 entry->SetIsSigninRequired(true); 267 entry->SetIsSigninRequired(true);
266 EXPECT_TRUE(entry->IsSigninRequired()); 268 EXPECT_TRUE(entry->IsSigninRequired());
267 269
268 EXPECT_EQ(1u, active_browser_list_->size()); 270 EXPECT_EQ(1u, active_browser_list_->size());
269 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO]; 271 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO];
(...skipping 15 matching lines...) Expand all
285 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, 287 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest,
286 MAYBE_GuestProfileReopenWithNoWindows) { 288 MAYBE_GuestProfileReopenWithNoWindows) {
287 // Create the system profile. Set the guest as the last used profile so the 289 // Create the system profile. Set the guest as the last used profile so the
288 // app controller can use it on init. 290 // app controller can use it on init.
289 CreateAndWaitForSystemProfile(); 291 CreateAndWaitForSystemProfile();
290 PrefService* local_state = g_browser_process->local_state(); 292 PrefService* local_state = g_browser_process->local_state();
291 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir); 293 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir);
292 294
293 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); 295 base::scoped_nsobject<AppController> ac([[AppController alloc] init]);
294 296
297 base::ThreadRestrictions::ScopedAllowIO allow_io;
295 Profile* profile = [ac lastProfile]; 298 Profile* profile = [ac lastProfile];
296 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), profile->GetPath()); 299 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), profile->GetPath());
297 EXPECT_TRUE(profile->IsGuestSession()); 300 EXPECT_TRUE(profile->IsGuestSession());
298 301
299 EXPECT_EQ(1u, active_browser_list_->size()); 302 EXPECT_EQ(1u, active_browser_list_->size());
300 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO]; 303 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO];
301 EXPECT_FALSE(result); 304 EXPECT_FALSE(result);
302 305
303 base::RunLoop().RunUntilIdle(); 306 base::RunLoop().RunUntilIdle();
304 307
(...skipping 14 matching lines...) Expand all
319 322
320 // Create the guest profile, and set it as the last used profile so the 323 // Create the guest profile, and set it as the last used profile so the
321 // app controller can use it on init. 324 // app controller can use it on init.
322 CreateAndWaitForSystemProfile(); 325 CreateAndWaitForSystemProfile();
323 PrefService* local_state = g_browser_process->local_state(); 326 PrefService* local_state = g_browser_process->local_state();
324 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir); 327 local_state->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir);
325 328
326 // Prohibiting guest mode forces the user manager flow for About Chrome. 329 // Prohibiting guest mode forces the user manager flow for About Chrome.
327 local_state->SetBoolean(prefs::kBrowserGuestModeEnabled, false); 330 local_state->SetBoolean(prefs::kBrowserGuestModeEnabled, false);
328 331
332 base::ThreadRestrictions::ScopedAllowIO allow_io;
329 Profile* guest_profile = [ac lastProfile]; 333 Profile* guest_profile = [ac lastProfile];
330 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), guest_profile->GetPath()); 334 EXPECT_EQ(ProfileManager::GetGuestProfilePath(), guest_profile->GetPath());
331 EXPECT_TRUE(guest_profile->IsGuestSession()); 335 EXPECT_TRUE(guest_profile->IsGuestSession());
332 336
333 // Tell the browser to open About Chrome. 337 // Tell the browser to open About Chrome.
334 EXPECT_EQ(1u, active_browser_list_->size()); 338 EXPECT_EQ(1u, active_browser_list_->size());
335 [ac orderFrontStandardAboutPanel:NSApp]; 339 [ac orderFrontStandardAboutPanel:NSApp];
336 340
337 base::RunLoop().RunUntilIdle(); 341 base::RunLoop().RunUntilIdle();
338 342
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 535
532 const base::string16 title2(base::ASCIIToUTF16("XKCD")); 536 const base::string16 title2(base::ASCIIToUTF16("XKCD"));
533 const GURL url2("https://www.xkcd.com/"); 537 const GURL url2("https://www.xkcd.com/");
534 538
535 // Use the existing profile as profile 1. 539 // Use the existing profile as profile 1.
536 Profile* profile1 = browser()->profile(); 540 Profile* profile1 = browser()->profile();
537 bookmarks::test::WaitForBookmarkModelToLoad( 541 bookmarks::test::WaitForBookmarkModelToLoad(
538 BookmarkModelFactory::GetForBrowserContext(profile1)); 542 BookmarkModelFactory::GetForBrowserContext(profile1));
539 543
540 // Create profile 2. 544 // Create profile 2.
545 base::ThreadRestrictions::ScopedAllowIO allow_io;
541 base::FilePath path2 = profile_manager->GenerateNextProfileDirectoryPath(); 546 base::FilePath path2 = profile_manager->GenerateNextProfileDirectoryPath();
542 Profile* profile2 = 547 Profile* profile2 =
543 Profile::CreateProfile(path2, NULL, Profile::CREATE_MODE_SYNCHRONOUS); 548 Profile::CreateProfile(path2, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
544 profile_manager->RegisterTestingProfile(profile2, false, true); 549 profile_manager->RegisterTestingProfile(profile2, false, true);
545 bookmarks::test::WaitForBookmarkModelToLoad( 550 bookmarks::test::WaitForBookmarkModelToLoad(
546 BookmarkModelFactory::GetForBrowserContext(profile2)); 551 BookmarkModelFactory::GetForBrowserContext(profile2));
547 552
548 // Switch to profile 1, create bookmark 1 and force the menu to build. 553 // Switch to profile 1, create bookmark 1 and force the menu to build.
549 [ac windowChangedToProfile:profile1]; 554 [ac windowChangedToProfile:profile1];
550 [ac bookmarkMenuBridge]->GetBookmarkModel()->AddURL( 555 [ac bookmarkMenuBridge]->GetBookmarkModel()->AddURL(
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 ui_test_utils::NavigateToURL(browser3, test_url1); 711 ui_test_utils::NavigateToURL(browser3, test_url1);
707 EXPECT_EQ(g_handoff_url, GURL()); 712 EXPECT_EQ(g_handoff_url, GURL());
708 713
709 // Activate the original browser window. 714 // Activate the original browser window.
710 Browser* browser1 = active_browser_list->get(0); 715 Browser* browser1 = active_browser_list->get(0);
711 browser1->window()->Show(); 716 browser1->window()->Show();
712 EXPECT_EQ(g_handoff_url, test_url2); 717 EXPECT_EQ(g_handoff_url, test_url2);
713 } 718 }
714 719
715 } // namespace 720 } // namespace
OLDNEW
« no previous file with comments | « base/test/multiprocess_test.cc ('k') | chrome/browser/apps/app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698