| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/apps/scoped_keep_alive.h" | |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 9 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
| 11 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/test/base/browser_with_test_window_test.h" | 12 #include "chrome/test/base/browser_with_test_window_test.h" |
| 14 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
| 15 #include "chrome/test/base/testing_profile_manager.h" | 14 #include "chrome/test/base/testing_profile_manager.h" |
| 16 #include "components/power/origin_power_map.h" | 15 #include "components/power/origin_power_map.h" |
| 17 #include "components/power/origin_power_map_factory.h" | 16 #include "components/power/origin_power_map_factory.h" |
| 18 #include "content/public/browser/site_instance.h" | 17 #include "content/public/browser/site_instance.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 manifest, | 259 manifest, |
| 261 extensions::Extension::NO_FLAGS, | 260 extensions::Extension::NO_FLAGS, |
| 262 kTestAppId, | 261 kTestAppId, |
| 263 &error)); | 262 &error)); |
| 264 EXPECT_TRUE(extension.get()) << error; | 263 EXPECT_TRUE(extension.get()) << error; |
| 265 | 264 |
| 266 Profile* current_profile = | 265 Profile* current_profile = |
| 267 profile_manager_->CreateTestingProfile("Test user"); | 266 profile_manager_->CreateTestingProfile("Test user"); |
| 268 GURL url("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | 267 GURL url("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
| 269 extensions::AppWindow* window = new extensions::AppWindow( | 268 extensions::AppWindow* window = new extensions::AppWindow( |
| 270 current_profile, new ChromeAppDelegate(scoped_ptr<ScopedKeepAlive>()), | 269 current_profile, new ChromeAppDelegate(false), extension.get()); |
| 271 extension.get()); | |
| 272 content::WebContents* web_contents( | 270 content::WebContents* web_contents( |
| 273 content::WebContents::Create(content::WebContents::CreateParams( | 271 content::WebContents::Create(content::WebContents::CreateParams( |
| 274 current_profile, | 272 current_profile, |
| 275 content::SiteInstance::CreateForURL(current_profile, url)))); | 273 content::SiteInstance::CreateForURL(current_profile, url)))); |
| 276 window->SetAppWindowContentsForTesting( | 274 window->SetAppWindowContentsForTesting( |
| 277 scoped_ptr<extensions::AppWindowContents>( | 275 scoped_ptr<extensions::AppWindowContents>( |
| 278 new extensions::TestAppWindowContents(web_contents))); | 276 new extensions::TestAppWindowContents(web_contents))); |
| 279 extensions::AppWindowRegistry* app_registry = | 277 extensions::AppWindowRegistry* app_registry = |
| 280 extensions::AppWindowRegistry::Get(current_profile); | 278 extensions::AppWindowRegistry::Get(current_profile); |
| 281 app_registry->AddAppWindow(window); | 279 app_registry->AddAppWindow(window); |
| 282 | 280 |
| 283 collector->set_cpu_usage_callback_for_testing( | 281 collector->set_cpu_usage_callback_for_testing( |
| 284 base::Bind(&BrowserProcessPowerTest::ReturnCpuAsConstant, | 282 base::Bind(&BrowserProcessPowerTest::ReturnCpuAsConstant, |
| 285 base::Unretained(this), | 283 base::Unretained(this), |
| 286 5)); | 284 5)); |
| 287 collector->UpdatePowerConsumptionForTesting(); | 285 collector->UpdatePowerConsumptionForTesting(); |
| 288 EXPECT_EQ(1u, collector->metrics_map_for_testing()->size()); | 286 EXPECT_EQ(1u, collector->metrics_map_for_testing()->size()); |
| 289 | 287 |
| 290 window->OnNativeClose(); | 288 window->OnNativeClose(); |
| 291 collector->UpdatePowerConsumptionForTesting(); | 289 collector->UpdatePowerConsumptionForTesting(); |
| 292 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); | 290 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); |
| 293 } | 291 } |
| OLD | NEW |