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

Side by Side Diff: chrome/browser/chromeos/power/extension_event_observer_unittest.cc

Issue 1136523004: [Sessions] Add detailed logging of SessionRestore events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo. Created 5 years, 6 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 | « no previous file | chrome/browser/sessions/session_restore_delegate.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 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"
(...skipping 12 matching lines...) Expand all
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/extension_host_observer.h" 26 #include "extensions/browser/extension_host_observer.h"
27 #include "extensions/browser/process_manager.h" 27 #include "extensions/browser/process_manager.h"
28 #include "extensions/common/extension.h" 28 #include "extensions/common/extension.h"
29 #include "extensions/common/extension_builder.h" 29 #include "extensions/common/extension_builder.h"
30 #include "extensions/common/manifest_handlers/background_info.h" 30 #include "extensions/common/manifest_handlers/background_info.h"
31 #include "extensions/common/value_builder.h" 31 #include "extensions/common/value_builder.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 #include "ui/aura/test/test_screen.h"
34 #include "ui/gfx/screen.h"
33 35
34 namespace chromeos { 36 namespace chromeos {
35 37
36 class ExtensionEventObserverTest : public ::testing::Test { 38 class ExtensionEventObserverTest : public ::testing::Test {
37 public: 39 public:
38 ExtensionEventObserverTest() 40 ExtensionEventObserverTest()
39 : power_manager_client_(new FakePowerManagerClient()), 41 : power_manager_client_(new FakePowerManagerClient()),
42 test_screen_(aura::TestScreen::Create(gfx::Size())),
40 fake_user_manager_(new FakeChromeUserManager()), 43 fake_user_manager_(new FakeChromeUserManager()),
41 scoped_user_manager_enabler_(fake_user_manager_) { 44 scoped_user_manager_enabler_(fake_user_manager_) {
42 DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( 45 DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient(
43 make_scoped_ptr(power_manager_client_)); 46 make_scoped_ptr(power_manager_client_));
44 47
45 profile_manager_.reset( 48 profile_manager_.reset(
46 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 49 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
47 50
48 extension_event_observer_.reset(new ExtensionEventObserver()); 51 extension_event_observer_.reset(new ExtensionEventObserver());
49 test_api_ = extension_event_observer_->CreateTestApi(); 52 test_api_ = extension_event_observer_->CreateTestApi();
50 } 53 }
51 54
52 ~ExtensionEventObserverTest() override { 55 ~ExtensionEventObserverTest() override {
53 extension_event_observer_.reset(); 56 extension_event_observer_.reset();
54 profile_manager_.reset(); 57 profile_manager_.reset();
55 DBusThreadManager::Shutdown(); 58 DBusThreadManager::Shutdown();
56 } 59 }
57 60
58 // ::testing::Test overrides. 61 // ::testing::Test overrides.
59 void SetUp() override { 62 void SetUp() override {
60 ::testing::Test::SetUp(); 63 ::testing::Test::SetUp();
61 64
65 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
66
62 // Must be called from ::testing::Test::SetUp. 67 // Must be called from ::testing::Test::SetUp.
63 ASSERT_TRUE(profile_manager_->SetUp()); 68 ASSERT_TRUE(profile_manager_->SetUp());
64 69
65 const char kUserProfile[] = "profile1@example.com"; 70 const char kUserProfile[] = "profile1@example.com";
66 fake_user_manager_->AddUser(kUserProfile); 71 fake_user_manager_->AddUser(kUserProfile);
67 fake_user_manager_->LoginUser(kUserProfile); 72 fake_user_manager_->LoginUser(kUserProfile);
68 profile_ = profile_manager_->CreateTestingProfile(kUserProfile); 73 profile_ = profile_manager_->CreateTestingProfile(kUserProfile);
69 74
70 profile_manager_->SetLoggedIn(true); 75 profile_manager_->SetLoggedIn(true);
71 } 76 }
72 void TearDown() override { 77 void TearDown() override {
73 profile_ = NULL; 78 profile_ = NULL;
74 profile_manager_->DeleteAllTestingProfiles(); 79 profile_manager_->DeleteAllTestingProfiles();
75 80 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
76 ::testing::Test::TearDown(); 81 ::testing::Test::TearDown();
77 } 82 }
78 83
79 protected: 84 protected:
80 scoped_refptr<extensions::Extension> CreateApp(const std::string& name, 85 scoped_refptr<extensions::Extension> CreateApp(const std::string& name,
81 bool uses_gcm) { 86 bool uses_gcm) {
82 scoped_refptr<extensions::Extension> app = 87 scoped_refptr<extensions::Extension> app =
83 extensions::ExtensionBuilder() 88 extensions::ExtensionBuilder()
84 .SetManifest( 89 .SetManifest(
85 extensions::DictionaryBuilder() 90 extensions::DictionaryBuilder()
(...skipping 29 matching lines...) Expand all
115 FakePowerManagerClient* power_manager_client_; 120 FakePowerManagerClient* power_manager_client_;
116 121
117 scoped_ptr<ExtensionEventObserver> extension_event_observer_; 122 scoped_ptr<ExtensionEventObserver> extension_event_observer_;
118 scoped_ptr<ExtensionEventObserver::TestApi> test_api_; 123 scoped_ptr<ExtensionEventObserver::TestApi> test_api_;
119 124
120 // Owned by |profile_manager_|. 125 // Owned by |profile_manager_|.
121 TestingProfile* profile_; 126 TestingProfile* profile_;
122 scoped_ptr<TestingProfileManager> profile_manager_; 127 scoped_ptr<TestingProfileManager> profile_manager_;
123 128
124 private: 129 private:
130 scoped_ptr<aura::TestScreen> test_screen_;
125 content::TestBrowserThreadBundle browser_thread_bundle_; 131 content::TestBrowserThreadBundle browser_thread_bundle_;
126 132
127 // Needed to ensure we don't end up creating actual RenderViewHosts 133 // Needed to ensure we don't end up creating actual RenderViewHosts
128 // and RenderProcessHosts. 134 // and RenderProcessHosts.
129 content::RenderViewHostTestEnabler render_view_host_test_enabler_; 135 content::RenderViewHostTestEnabler render_view_host_test_enabler_;
130 136
131 // Chrome OS needs extra services to run in the following order. 137 // Chrome OS needs extra services to run in the following order.
132 ScopedTestDeviceSettingsService test_device_settings_service_; 138 ScopedTestDeviceSettingsService test_device_settings_service_;
133 ScopedTestCrosSettings test_cros_settings_; 139 ScopedTestCrosSettings test_cros_settings_;
134 140
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback()); 317 EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback());
312 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks()); 318 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks());
313 319
314 // Test that the ExtensionEventObserver does not delay suspend attempts when 320 // Test that the ExtensionEventObserver does not delay suspend attempts when
315 // it is disabled. 321 // it is disabled.
316 power_manager_client_->SendDarkSuspendImminent(); 322 power_manager_client_->SendDarkSuspendImminent();
317 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks()); 323 EXPECT_EQ(0, power_manager_client_->GetNumPendingSuspendReadinessCallbacks());
318 } 324 }
319 325
320 } // namespace chromeos 326 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698