| OLD | NEW |
| 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/lifetime/application_lifetime.h" | 9 #include "chrome/browser/lifetime/application_lifetime.h" |
| 10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/base/testing_browser_process.h" | 12 #include "chrome/test/base/testing_browser_process.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "chrome/test/base/testing_profile_manager.h" | 14 #include "chrome/test/base/testing_profile_manager.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/image/image_unittest_util.h" | 18 #include "ui/gfx/image/image_unittest_util.h" |
| 19 #include "ui/message_center/message_center.h" |
| 18 | 20 |
| 19 class BackgroundModeManagerTest : public testing::Test { | 21 class BackgroundModeManagerTest : public testing::Test { |
| 20 public: | 22 public: |
| 21 BackgroundModeManagerTest() | 23 BackgroundModeManagerTest() |
| 22 : profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 24 : profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
| 23 virtual ~BackgroundModeManagerTest() {} | 25 virtual ~BackgroundModeManagerTest() {} |
| 24 virtual void SetUp() { | 26 virtual void SetUp() { |
| 25 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 27 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
| 26 ASSERT_TRUE(profile_manager_.SetUp()); | 28 ASSERT_TRUE(profile_manager_.SetUp()); |
| 27 } | 29 } |
| 30 static void SetUpTestCase() { |
| 31 message_center::MessageCenter::Initialize(); |
| 32 } |
| 33 static void TearDownTestCase() { |
| 34 message_center::MessageCenter::Shutdown(); |
| 35 } |
| 28 scoped_ptr<CommandLine> command_line_; | 36 scoped_ptr<CommandLine> command_line_; |
| 37 content::TestBrowserThreadBundle thread_bundle_; |
| 29 TestingProfileManager profile_manager_; | 38 TestingProfileManager profile_manager_; |
| 30 }; | 39 }; |
| 31 | 40 |
| 32 class TestBackgroundModeManager : public BackgroundModeManager { | 41 class TestBackgroundModeManager : public BackgroundModeManager { |
| 33 public: | 42 public: |
| 34 TestBackgroundModeManager( | 43 TestBackgroundModeManager( |
| 35 CommandLine* command_line, ProfileInfoCache* cache, bool enabled) | 44 CommandLine* command_line, ProfileInfoCache* cache, bool enabled) |
| 36 : BackgroundModeManager(command_line, cache), | 45 : BackgroundModeManager(command_line, cache), |
| 37 enabled_(enabled), | 46 enabled_(enabled), |
| 38 app_count_(0), | 47 app_count_(0), |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 312 |
| 304 TEST_F(BackgroundModeManagerTest, | 313 TEST_F(BackgroundModeManagerTest, |
| 305 BackgroundModeDisabledPreventsKeepAliveOnStartup) { | 314 BackgroundModeDisabledPreventsKeepAliveOnStartup) { |
| 306 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1"); | 315 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1"); |
| 307 command_line_->AppendSwitch(switches::kKeepAliveForTest); | 316 command_line_->AppendSwitch(switches::kKeepAliveForTest); |
| 308 TestBackgroundModeManager manager( | 317 TestBackgroundModeManager manager( |
| 309 command_line_.get(), profile_manager_.profile_info_cache(), false); | 318 command_line_.get(), profile_manager_.profile_info_cache(), false); |
| 310 manager.RegisterProfile(profile1); | 319 manager.RegisterProfile(profile1); |
| 311 EXPECT_FALSE(manager.ShouldBeInBackgroundMode()); | 320 EXPECT_FALSE(manager.ShouldBeInBackgroundMode()); |
| 312 } | 321 } |
| OLD | NEW |