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

Side by Side Diff: chrome/browser/power/process_power_collector_unittest.cc

Issue 1376063005: Cleanup: Pull some browser keep alive functions into its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 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
OLDNEW
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/lifetime/browser_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"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/browser_with_test_window_test.h" 12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "chrome/test/base/testing_browser_process.h" 13 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile_manager.h" 14 #include "chrome/test/base/testing_profile_manager.h"
15 #include "components/power/origin_power_map.h" 15 #include "components/power/origin_power_map.h"
16 #include "components/power/origin_power_map_factory.h" 16 #include "components/power/origin_power_map_factory.h"
17 #include "content/public/browser/site_instance.h" 17 #include "content/public/browser/site_instance.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 manifest, 263 manifest,
264 extensions::Extension::NO_FLAGS, 264 extensions::Extension::NO_FLAGS,
265 kTestAppId, 265 kTestAppId,
266 &error)); 266 &error));
267 EXPECT_TRUE(extension.get()) << error; 267 EXPECT_TRUE(extension.get()) << error;
268 268
269 Profile* current_profile = 269 Profile* current_profile =
270 profile_manager_->CreateTestingProfile("Test user"); 270 profile_manager_->CreateTestingProfile("Test user");
271 GURL url("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 271 GURL url("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
272 extensions::AppWindow* window = new extensions::AppWindow( 272 extensions::AppWindow* window = new extensions::AppWindow(
273 current_profile, new ChromeAppDelegate(scoped_ptr<ScopedKeepAlive>()), 273 current_profile,
274 new ChromeAppDelegate(scoped_ptr<browser_lifetime::ScopedKeepAlive>()),
274 extension.get()); 275 extension.get());
275 content::WebContents* web_contents( 276 content::WebContents* web_contents(
276 content::WebContents::Create(content::WebContents::CreateParams( 277 content::WebContents::Create(content::WebContents::CreateParams(
277 current_profile, 278 current_profile,
278 content::SiteInstance::CreateForURL(current_profile, url)))); 279 content::SiteInstance::CreateForURL(current_profile, url))));
279 window->SetAppWindowContentsForTesting( 280 window->SetAppWindowContentsForTesting(
280 scoped_ptr<extensions::AppWindowContents>( 281 scoped_ptr<extensions::AppWindowContents>(
281 new extensions::TestAppWindowContents(web_contents))); 282 new extensions::TestAppWindowContents(web_contents)));
282 extensions::AppWindowRegistry* app_registry = 283 extensions::AppWindowRegistry* app_registry =
283 extensions::AppWindowRegistry::Get(current_profile); 284 extensions::AppWindowRegistry::Get(current_profile);
284 app_registry->AddAppWindow(window); 285 app_registry->AddAppWindow(window);
285 286
286 collector->set_cpu_usage_callback_for_testing( 287 collector->set_cpu_usage_callback_for_testing(
287 base::Bind(&BrowserProcessPowerTest::ReturnCpuAsConstant, 288 base::Bind(&BrowserProcessPowerTest::ReturnCpuAsConstant,
288 base::Unretained(this), 289 base::Unretained(this),
289 5)); 290 5));
290 collector->UpdatePowerConsumptionForTesting(); 291 collector->UpdatePowerConsumptionForTesting();
291 EXPECT_EQ(1u, collector->metrics_map_for_testing()->size()); 292 EXPECT_EQ(1u, collector->metrics_map_for_testing()->size());
292 293
293 window->OnNativeClose(); 294 window->OnNativeClose();
294 collector->UpdatePowerConsumptionForTesting(); 295 collector->UpdatePowerConsumptionForTesting();
295 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size()); 296 EXPECT_EQ(0u, collector->metrics_map_for_testing()->size());
296 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698