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

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

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 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 | 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/background/background_mode_manager.h" 8 #include "chrome/browser/background/background_mode_manager.h"
9 #include "chrome/browser/browser_shutdown.h"
9 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
11 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
12 #include "chrome/test/base/testing_browser_process.h" 13 #include "chrome/test/base/testing_browser_process.h"
13 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
14 #include "chrome/test/base/testing_profile_manager.h" 15 #include "chrome/test/base/testing_profile_manager.h"
16 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/image/image_unittest_util.h" 19 #include "ui/gfx/image/image_unittest_util.h"
20 #include "ui/message_center/message_center.h"
18 21
19 class BackgroundModeManagerTest : public testing::Test { 22 class BackgroundModeManagerTest : public testing::Test {
20 public: 23 protected:
21 BackgroundModeManagerTest() 24 BackgroundModeManagerTest()
22 : profile_manager_(TestingBrowserProcess::GetGlobal()) {} 25 : profile_manager_(TestingBrowserProcess::GetGlobal()) {
23 virtual ~BackgroundModeManagerTest() {}
24 virtual void SetUp() {
25 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); 26 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM));
26 ASSERT_TRUE(profile_manager_.SetUp()); 27 CHECK(profile_manager_.SetUp());
28 #if defined(OS_CHROMEOS)
29 // Because of the http://crbug.com/119175 workaround in the test
30 // constructor, browser shutdown needs to be reset otherwise
31 // subsequent test will fail.
32 browser_shutdown::SetTryingToQuit(false);
33 #endif // defined(OS_CHROMEOS)
27 } 34 }
35
36 static void SetUpTestCase() {
37 message_center::MessageCenter::Initialize();
38 #if defined(OS_CHROMEOS)
39 // Needed to handle http://crbug.com/119175.
40 CommandLine::ForCurrentProcess()->AppendSwitch(
41 switches::kDisableZeroBrowsersOpenForTests);
42 #endif // defined(OS_CHROMEOS)
43 }
44 static void TearDownTestCase() {
45 message_center::MessageCenter::Shutdown();
46 }
47
28 scoped_ptr<CommandLine> command_line_; 48 scoped_ptr<CommandLine> command_line_;
49 content::TestBrowserThreadBundle thread_bundle_;
29 TestingProfileManager profile_manager_; 50 TestingProfileManager profile_manager_;
30 }; 51 };
31 52
32 class TestBackgroundModeManager : public BackgroundModeManager { 53 class TestBackgroundModeManager : public BackgroundModeManager {
33 public: 54 public:
34 TestBackgroundModeManager( 55 TestBackgroundModeManager(
35 CommandLine* command_line, ProfileInfoCache* cache, bool enabled) 56 CommandLine* command_line, ProfileInfoCache* cache, bool enabled)
36 : BackgroundModeManager(command_line, cache), 57 : BackgroundModeManager(command_line, cache),
37 enabled_(enabled), 58 enabled_(enabled),
38 app_count_(0), 59 app_count_(0),
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 324
304 TEST_F(BackgroundModeManagerTest, 325 TEST_F(BackgroundModeManagerTest,
305 BackgroundModeDisabledPreventsKeepAliveOnStartup) { 326 BackgroundModeDisabledPreventsKeepAliveOnStartup) {
306 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1"); 327 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1");
307 command_line_->AppendSwitch(switches::kKeepAliveForTest); 328 command_line_->AppendSwitch(switches::kKeepAliveForTest);
308 TestBackgroundModeManager manager( 329 TestBackgroundModeManager manager(
309 command_line_.get(), profile_manager_.profile_info_cache(), false); 330 command_line_.get(), profile_manager_.profile_info_cache(), false);
310 manager.RegisterProfile(profile1); 331 manager.RegisterProfile(profile1);
311 EXPECT_FALSE(manager.ShouldBeInBackgroundMode()); 332 EXPECT_FALSE(manager.ShouldBeInBackgroundMode());
312 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698