OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/power/process_power_collector.h" | 5 #include "chrome/browser/power/process_power_collector.h" |
6 | 6 |
7 #include "chrome/browser/apps/scoped_keep_alive.h" | 7 #include "chrome/browser/apps/scoped_keep_alive.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 9 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 scoped_ptr<ProcessPowerCollector> collector; | 88 scoped_ptr<ProcessPowerCollector> collector; |
89 scoped_ptr<TestingProfileManager> profile_manager_; | 89 scoped_ptr<TestingProfileManager> profile_manager_; |
90 }; | 90 }; |
91 | 91 |
92 class TestAppWindowContents : public extensions::AppWindowContents { | 92 class TestAppWindowContents : public extensions::AppWindowContents { |
93 public: | 93 public: |
94 explicit TestAppWindowContents(content::WebContents* web_contents) | 94 explicit TestAppWindowContents(content::WebContents* web_contents) |
95 : web_contents_(web_contents) {} | 95 : web_contents_(web_contents) {} |
96 | 96 |
97 // apps:AppWindowContents | 97 // apps:AppWindowContents |
98 virtual void Initialize(content::BrowserContext* context, | 98 void Initialize(content::BrowserContext* context, const GURL& url) override {} |
99 const GURL& url) override {} | 99 void LoadContents(int32 creator_process_id) override {} |
100 virtual void LoadContents(int32 creator_process_id) override {} | 100 void NativeWindowChanged( |
101 virtual void NativeWindowChanged( | |
102 extensions::NativeAppWindow* native_app_window) override {} | 101 extensions::NativeAppWindow* native_app_window) override {} |
103 virtual void NativeWindowClosed() override {} | 102 void NativeWindowClosed() override {} |
104 virtual void DispatchWindowShownForTests() const override {} | 103 void DispatchWindowShownForTests() const override {} |
105 virtual content::WebContents* GetWebContents() const override { | 104 content::WebContents* GetWebContents() const override { |
106 return web_contents_.get(); | 105 return web_contents_.get(); |
107 } | 106 } |
108 | 107 |
109 private: | 108 private: |
110 scoped_ptr<content::WebContents> web_contents_; | 109 scoped_ptr<content::WebContents> web_contents_; |
111 }; | 110 }; |
112 | 111 |
113 TEST_F(BrowserProcessPowerTest, NoSite) { | 112 TEST_F(BrowserProcessPowerTest, NoSite) { |
114 collector->UpdatePowerConsumptionForTesting(); | 113 collector->UpdatePowerConsumptionForTesting(); |
115 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); | 114 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 collector->UpdatePowerConsumptionForTesting(); | 311 collector->UpdatePowerConsumptionForTesting(); |
313 EXPECT_EQ(1u, collector->metrics_map_for_testing()->size()); | 312 EXPECT_EQ(1u, collector->metrics_map_for_testing()->size()); |
314 | 313 |
315 // Clear the AppWindowContents before trying to close. | 314 // Clear the AppWindowContents before trying to close. |
316 window->SetAppWindowContentsForTesting( | 315 window->SetAppWindowContentsForTesting( |
317 scoped_ptr<extensions::AppWindowContents>()); | 316 scoped_ptr<extensions::AppWindowContents>()); |
318 window->OnNativeClose(); | 317 window->OnNativeClose(); |
319 collector->UpdatePowerConsumptionForTesting(); | 318 collector->UpdatePowerConsumptionForTesting(); |
320 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); | 319 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); |
321 } | 320 } |
OLD | NEW |