OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/power/extension_event_observer.h" | 5 #include "chrome/browser/chromeos/power/extension_event_observer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
15 #include "chrome/browser/chromeos/settings/cros_settings.h" | 15 #include "chrome/browser/chromeos/settings/cros_settings.h" |
16 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 16 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
17 #include "chrome/common/extensions/api/gcm.h" | 17 #include "chrome/common/extensions/api/gcm.h" |
18 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
20 #include "chrome/test/base/testing_profile_manager.h" | 20 #include "chrome/test/base/testing_profile_manager.h" |
21 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
22 #include "chromeos/dbus/fake_power_manager_client.h" | 22 #include "chromeos/dbus/fake_power_manager_client.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "content/public/test/test_renderer_host.h" | 24 #include "content/public/test/test_renderer_host.h" |
25 #include "extensions/browser/extension_host.h" | 25 #include "extensions/browser/extension_host.h" |
26 #include "extensions/browser/process_manager.h" | 26 #include "extensions/browser/process_manager.h" |
27 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
28 #include "extensions/common/extension_builder.h" | 28 #include "extensions/common/extension_builder.h" |
29 #include "extensions/common/manifest_handlers/background_info.h" | 29 #include "extensions/common/manifest_handlers/background_info.h" |
30 #include "extensions/common/value_builder.h" | 30 #include "extensions/common/value_builder.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 | 32 |
33 namespace chromeos { | 33 namespace chromeos { |
34 | 34 |
35 class ExtensionEventObserverTest : public ::testing::Test { | 35 class ExtensionEventObserverTest : public ::testing::Test { |
36 public: | 36 public: |
37 ExtensionEventObserverTest() | 37 ExtensionEventObserverTest() |
38 : power_manager_client_(new FakePowerManagerClient()), | 38 : power_manager_client_(new FakePowerManagerClient()), |
39 fake_user_manager_(new FakeUserManager()), | 39 fake_user_manager_(new FakeChromeUserManager()), |
40 scoped_user_manager_enabler_(fake_user_manager_) { | 40 scoped_user_manager_enabler_(fake_user_manager_) { |
41 DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( | 41 DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( |
42 make_scoped_ptr(power_manager_client_)); | 42 make_scoped_ptr(power_manager_client_)); |
43 | 43 |
44 profile_manager_.reset( | 44 profile_manager_.reset( |
45 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 45 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
46 | 46 |
47 extension_event_observer_.reset(new ExtensionEventObserver()); | 47 extension_event_observer_.reset(new ExtensionEventObserver()); |
48 test_api_ = extension_event_observer_->CreateTestApi(); | 48 test_api_ = extension_event_observer_->CreateTestApi(); |
49 } | 49 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 // Needed to ensure we don't end up creating actual RenderViewHosts | 126 // Needed to ensure we don't end up creating actual RenderViewHosts |
127 // and RenderProcessHosts. | 127 // and RenderProcessHosts. |
128 content::RenderViewHostTestEnabler render_view_host_test_enabler_; | 128 content::RenderViewHostTestEnabler render_view_host_test_enabler_; |
129 | 129 |
130 // Chrome OS needs extra services to run in the following order. | 130 // Chrome OS needs extra services to run in the following order. |
131 ScopedTestDeviceSettingsService test_device_settings_service_; | 131 ScopedTestDeviceSettingsService test_device_settings_service_; |
132 ScopedTestCrosSettings test_cros_settings_; | 132 ScopedTestCrosSettings test_cros_settings_; |
133 | 133 |
134 // Owned by |scoped_user_manager_enabler_|. | 134 // Owned by |scoped_user_manager_enabler_|. |
135 FakeUserManager* fake_user_manager_; | 135 FakeChromeUserManager* fake_user_manager_; |
136 ScopedUserManagerEnabler scoped_user_manager_enabler_; | 136 ScopedUserManagerEnabler scoped_user_manager_enabler_; |
137 | 137 |
138 std::vector<scoped_refptr<extensions::Extension>> created_apps_; | 138 std::vector<scoped_refptr<extensions::Extension>> created_apps_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(ExtensionEventObserverTest); | 140 DISALLOW_COPY_AND_ASSIGN(ExtensionEventObserverTest); |
141 }; | 141 }; |
142 | 142 |
143 // Tests that the ExtensionEventObserver reports readiness for suspend when | 143 // Tests that the ExtensionEventObserver reports readiness for suspend when |
144 // there is nothing interesting going on. | 144 // there is nothing interesting going on. |
145 TEST_F(ExtensionEventObserverTest, BasicSuspendAndDarkSuspend) { | 145 TEST_F(ExtensionEventObserverTest, BasicSuspendAndDarkSuspend) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback()); | 310 EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback()); |
311 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks()); | 311 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks()); |
312 | 312 |
313 // Test that the ExtensionEventObserver does not delay suspend attempts when | 313 // Test that the ExtensionEventObserver does not delay suspend attempts when |
314 // it is disabled. | 314 // it is disabled. |
315 power_manager_client_->SendDarkSuspendImminent(); | 315 power_manager_client_->SendDarkSuspendImminent(); |
316 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks()); | 316 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks()); |
317 } | 317 } |
318 | 318 |
319 } // namespace chromeos | 319 } // namespace chromeos |
OLD | NEW |