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

Unified Diff: chrome/browser/power/process_power_collector_unittest.cc

Issue 507773006: Fix a bug where an AppWindow* was not being properly deleted in the BrowserProcessPowerTest.AppsRec… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/power/process_power_collector_unittest.cc
diff --git a/chrome/browser/power/process_power_collector_unittest.cc b/chrome/browser/power/process_power_collector_unittest.cc
index 0a21e34b3a622dfd430169867f377b191cd6042b..560d4abe88de019e2123a18c8a900013e861f519 100644
--- a/chrome/browser/power/process_power_collector_unittest.cc
+++ b/chrome/browser/power/process_power_collector_unittest.cc
@@ -6,6 +6,7 @@
#include "apps/app_window_contents.h"
#include "apps/app_window_registry.h"
+#include "apps/ui/apps_client.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/apps/chrome_app_delegate.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -285,18 +286,20 @@ TEST_F(BrowserProcessPowerTest, AppsRecordPowerUsage) {
kTestAppId,
&error));
EXPECT_TRUE(extension.get()) << error;
+ // Increment the apps count to avoid a DCHECK later.
+ apps::AppsClient::Get()->IncrementKeepAliveCount();
Profile* current_profile =
profile_manager_->CreateTestingProfile("Test user");
GURL url("chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
apps::AppWindow* window =
new apps::AppWindow(current_profile, new ChromeAppDelegate(), extension);
- scoped_ptr<content::WebContents> web_contents(
+ content::WebContents* web_contents(
content::WebContents::Create(content::WebContents::CreateParams(
current_profile,
content::SiteInstance::CreateForURL(current_profile, url))));
window->SetAppWindowContentsForTesting(scoped_ptr<apps::AppWindowContents>(
- new TestAppWindowContents(web_contents.get())));
+ new TestAppWindowContents(web_contents)));
apps::AppWindowRegistry* app_registry =
apps::AppWindowRegistry::Get(current_profile);
app_registry->AddAppWindow(window);
@@ -308,7 +311,9 @@ TEST_F(BrowserProcessPowerTest, AppsRecordPowerUsage) {
collector->UpdatePowerConsumptionForTesting();
EXPECT_EQ(1u, collector->metrics_map_for_testing()->size());
- app_registry->RemoveAppWindow(window);
+ // Clear the AppWindowContents before trying to close.
+ window->SetAppWindowContentsForTesting(scoped_ptr<apps::AppWindowContents>());
+ window->OnNativeClose();
collector->UpdatePowerConsumptionForTesting();
EXPECT_EQ(0u, collector->metrics_map_for_testing()->size());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698