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

Side by Side Diff: chrome/browser/background/background_mode_manager_unittest.cc

Issue 176363002: Rename Start/EndKeepAlive to Increment/DecrementKeepAliveCount (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (rename_keep_alive) Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/background/background_mode_manager.h" 9 #include "chrome/browser/background/background_mode_manager.h"
10 #include "chrome/browser/browser_shutdown.h" 10 #include "chrome/browser/browser_shutdown.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // Required for extension service. 413 // Required for extension service.
414 content::TestBrowserThreadBundle thread_bundle; 414 content::TestBrowserThreadBundle thread_bundle;
415 415
416 scoped_ptr<TestingProfileManager> profile_manager = 416 scoped_ptr<TestingProfileManager> profile_manager =
417 CreateTestingProfileManager(); 417 CreateTestingProfileManager();
418 418
419 // BackgroundModeManager actually affects Chrome start/stop state, 419 // BackgroundModeManager actually affects Chrome start/stop state,
420 // tearing down our thread bundle before we've had chance to clean 420 // tearing down our thread bundle before we've had chance to clean
421 // everything up. Keeping Chrome alive prevents this. 421 // everything up. Keeping Chrome alive prevents this.
422 // We aren't interested in if the keep alive works correctly in this test. 422 // We aren't interested in if the keep alive works correctly in this test.
423 chrome::StartKeepAlive(); 423 chrome::IncrementKeepAliveCount();
424 TestingProfile* profile = profile_manager->CreateTestingProfile("p"); 424 TestingProfile* profile = profile_manager->CreateTestingProfile("p");
425 425
426 #if defined(OS_CHROMEOS) 426 #if defined(OS_CHROMEOS)
427 // ChromeOS needs extra services to run in the following order. 427 // ChromeOS needs extra services to run in the following order.
428 chromeos::ScopedTestDeviceSettingsService test_device_settings_service; 428 chromeos::ScopedTestDeviceSettingsService test_device_settings_service;
429 chromeos::ScopedTestCrosSettings test_cros_settings; 429 chromeos::ScopedTestCrosSettings test_cros_settings;
430 chromeos::ScopedTestUserManager test_user_manager; 430 chromeos::ScopedTestUserManager test_user_manager;
431 431
432 // On ChromeOS shutdown, HandleAppExitingForPlatform will call 432 // On ChromeOS shutdown, HandleAppExitingForPlatform will call
433 // chrome::EndKeepAlive because it assumes the aura shell 433 // chrome::DecrementKeepAliveCount because it assumes the aura shell
434 // called chrome::StartKeepAlive. Simulate the call here. 434 // called chrome::IncrementKeepAliveCount. Simulate the call here.
435 chrome::StartKeepAlive(); 435 chrome::IncrementKeepAliveCount();
436 #endif 436 #endif
437 437
438 scoped_refptr<extensions::Extension> component_extension( 438 scoped_refptr<extensions::Extension> component_extension(
439 CreateExtension( 439 CreateExtension(
440 extensions::Manifest::COMPONENT, 440 extensions::Manifest::COMPONENT,
441 "{\"name\": \"Component Extension\"," 441 "{\"name\": \"Component Extension\","
442 "\"version\": \"1.0\"," 442 "\"version\": \"1.0\","
443 "\"manifest_version\": 2," 443 "\"manifest_version\": 2,"
444 "\"permissions\": [\"background\"]}", 444 "\"permissions\": [\"background\"]}",
445 "ID-1")); 445 "ID-1"));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 base::UTF8ToUTF16("Regular Extension with Options")); 512 base::UTF8ToUTF16("Regular Extension with Options"));
513 EXPECT_TRUE(submenu->IsCommandIdEnabled(submenu->GetCommandIdAt(3))); 513 EXPECT_TRUE(submenu->IsCommandIdEnabled(submenu->GetCommandIdAt(3)));
514 514
515 // We have to destroy the profile now because we created it with real thread 515 // We have to destroy the profile now because we created it with real thread
516 // state. This causes a lot of machinery to spin up that stops working 516 // state. This causes a lot of machinery to spin up that stops working
517 // when we tear down our thread state at the end of the test. 517 // when we tear down our thread state at the end of the test.
518 profile_manager->DeleteTestingProfile("p"); 518 profile_manager->DeleteTestingProfile("p");
519 519
520 // We're getting ready to shutdown the message loop. Clear everything out! 520 // We're getting ready to shutdown the message loop. Clear everything out!
521 base::MessageLoop::current()->RunUntilIdle(); 521 base::MessageLoop::current()->RunUntilIdle();
522 chrome::EndKeepAlive(); // Matching the above chrome::StartKeepAlive(). 522 chrome::DecrementKeepAliveCount(); // Matching the above
523 // chrome::IncrementKeepAliveCount().
523 524
524 // TestBackgroundModeManager has dependencies on the infrastructure. 525 // TestBackgroundModeManager has dependencies on the infrastructure.
525 // It should get cleared first. 526 // It should get cleared first.
526 manager.reset(); 527 manager.reset();
527 528
528 // The Profile Manager references the Browser Process. 529 // The Profile Manager references the Browser Process.
529 // The Browser Process references the Notification UI Manager. 530 // The Browser Process references the Notification UI Manager.
530 // The Notification UI Manager references the Message Center. 531 // The Notification UI Manager references the Message Center.
531 // As a result, we have to clear the browser process state here 532 // As a result, we have to clear the browser process state here
532 // before tearing down the Message Center. 533 // before tearing down the Message Center.
533 profile_manager.reset(); 534 profile_manager.reset();
534 535
535 // Message Center shutdown must occur after the EndKeepAlive because 536 // Message Center shutdown must occur after the DecrementKeepAliveCount
536 // EndKeepAlive will end up referencing the message center during cleanup. 537 // because DecrementKeepAliveCount will end up referencing the message
538 // center during cleanup.
537 message_center::MessageCenter::Shutdown(); 539 message_center::MessageCenter::Shutdown();
538 540
539 // Clear the shutdown flag to isolate the remaining effect of this test. 541 // Clear the shutdown flag to isolate the remaining effect of this test.
540 browser_shutdown::SetTryingToQuit(false); 542 browser_shutdown::SetTryingToQuit(false);
541 } 543 }
542 544
543 TEST_F(BackgroundModeManagerTest, BackgroundMenuGenerationMultipleProfile) { 545 TEST_F(BackgroundModeManagerTest, BackgroundMenuGenerationMultipleProfile) {
544 // Aura clears notifications from the message center at shutdown. 546 // Aura clears notifications from the message center at shutdown.
545 message_center::MessageCenter::Initialize(); 547 message_center::MessageCenter::Initialize();
546 548
547 // Required for extension service. 549 // Required for extension service.
548 content::TestBrowserThreadBundle thread_bundle; 550 content::TestBrowserThreadBundle thread_bundle;
549 551
550 scoped_ptr<TestingProfileManager> profile_manager = 552 scoped_ptr<TestingProfileManager> profile_manager =
551 CreateTestingProfileManager(); 553 CreateTestingProfileManager();
552 554
553 // BackgroundModeManager actually affects Chrome start/stop state, 555 // BackgroundModeManager actually affects Chrome start/stop state,
554 // tearing down our thread bundle before we've had chance to clean 556 // tearing down our thread bundle before we've had chance to clean
555 // everything up. Keeping Chrome alive prevents this. 557 // everything up. Keeping Chrome alive prevents this.
556 // We aren't interested in if the keep alive works correctly in this test. 558 // We aren't interested in if the keep alive works correctly in this test.
557 chrome::StartKeepAlive(); 559 chrome::IncrementKeepAliveCount();
558 TestingProfile* profile1 = profile_manager->CreateTestingProfile("p1"); 560 TestingProfile* profile1 = profile_manager->CreateTestingProfile("p1");
559 TestingProfile* profile2 = profile_manager->CreateTestingProfile("p2"); 561 TestingProfile* profile2 = profile_manager->CreateTestingProfile("p2");
560 562
561 #if defined(OS_CHROMEOS) 563 #if defined(OS_CHROMEOS)
562 // ChromeOS needs extensionsra services to run in the following order. 564 // ChromeOS needs extensionsra services to run in the following order.
563 chromeos::ScopedTestDeviceSettingsService test_device_settings_service; 565 chromeos::ScopedTestDeviceSettingsService test_device_settings_service;
564 chromeos::ScopedTestCrosSettings test_cros_settings; 566 chromeos::ScopedTestCrosSettings test_cros_settings;
565 chromeos::ScopedTestUserManager test_user_manager; 567 chromeos::ScopedTestUserManager test_user_manager;
566 568
567 // On ChromeOS shutdown, HandleAppExitingForPlatform will call 569 // On ChromeOS shutdown, HandleAppExitingForPlatform will call
568 // chrome::EndKeepAlive because it assumes the aura shell 570 // chrome::DecrementKeepAliveCount because it assumes the aura shell
569 // called chrome::StartKeepAlive. Simulate the call here. 571 // called chrome::IncrementKeepAliveCount. Simulate the call here.
570 chrome::StartKeepAlive(); 572 chrome::IncrementKeepAliveCount();
571 #endif 573 #endif
572 574
573 scoped_refptr<extensions::Extension> component_extension( 575 scoped_refptr<extensions::Extension> component_extension(
574 CreateExtension( 576 CreateExtension(
575 extensions::Manifest::COMPONENT, 577 extensions::Manifest::COMPONENT,
576 "{\"name\": \"Component Extension\"," 578 "{\"name\": \"Component Extension\","
577 "\"version\": \"1.0\"," 579 "\"version\": \"1.0\","
578 "\"manifest_version\": 2," 580 "\"manifest_version\": 2,"
579 "\"permissions\": [\"background\"]}", 581 "\"permissions\": [\"background\"]}",
580 "ID-1")); 582 "ID-1"));
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 delete status_icon; 737 delete status_icon;
736 738
737 // We have to destroy the profiles now because we created them with real 739 // We have to destroy the profiles now because we created them with real
738 // thread state. This causes a lot of machinery to spin up that stops working 740 // thread state. This causes a lot of machinery to spin up that stops working
739 // when we tear down our thread state at the end of the test. 741 // when we tear down our thread state at the end of the test.
740 profile_manager->DeleteTestingProfile("p2"); 742 profile_manager->DeleteTestingProfile("p2");
741 profile_manager->DeleteTestingProfile("p1"); 743 profile_manager->DeleteTestingProfile("p1");
742 744
743 // We're getting ready to shutdown the message loop. Clear everything out! 745 // We're getting ready to shutdown the message loop. Clear everything out!
744 base::MessageLoop::current()->RunUntilIdle(); 746 base::MessageLoop::current()->RunUntilIdle();
745 chrome::EndKeepAlive(); // Matching the above chrome::StartKeepAlive(). 747 chrome::DecrementKeepAliveCount(); // Matching the above
748 // chrome::IncrementKeepAliveCount().
746 749
747 // TestBackgroundModeManager has dependencies on the infrastructure. 750 // TestBackgroundModeManager has dependencies on the infrastructure.
748 // It should get cleared first. 751 // It should get cleared first.
749 manager.reset(); 752 manager.reset();
750 753
751 // The Profile Manager references the Browser Process. 754 // The Profile Manager references the Browser Process.
752 // The Browser Process references the Notification UI Manager. 755 // The Browser Process references the Notification UI Manager.
753 // The Notification UI Manager references the Message Center. 756 // The Notification UI Manager references the Message Center.
754 // As a result, we have to clear the browser process state here 757 // As a result, we have to clear the browser process state here
755 // before tearing down the Message Center. 758 // before tearing down the Message Center.
756 profile_manager.reset(); 759 profile_manager.reset();
757 760
758 // Message Center shutdown must occur after the EndKeepAlive because 761 // Message Center shutdown must occur after the DecrementKeepAliveCount
759 // EndKeepAlive will end up referencing the message center during cleanup. 762 // because DecrementKeepAliveCount will end up referencing the message
763 // center during cleanup.
760 message_center::MessageCenter::Shutdown(); 764 message_center::MessageCenter::Shutdown();
761 765
762 // Clear the shutdown flag to isolate the remaining effect of this test. 766 // Clear the shutdown flag to isolate the remaining effect of this test.
763 browser_shutdown::SetTryingToQuit(false); 767 browser_shutdown::SetTryingToQuit(false);
764 } 768 }
OLDNEW
« no previous file with comments | « chrome/browser/background/background_mode_manager.cc ('k') | chrome/browser/chromeos/login/login_display_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698