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

Unified Diff: chrome/browser/extensions/extension_crash_recovery_browsertest.cc

Issue 8789018: Revert 113047 - Make ExtensionService use ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
Index: chrome/browser/extensions/extension_crash_recovery_browsertest.cc
===================================================================
--- chrome/browser/extensions/extension_crash_recovery_browsertest.cc (revision 113069)
+++ chrome/browser/extensions/extension_crash_recovery_browsertest.cc (working copy)
@@ -62,10 +62,12 @@
return balloons.size();
}
- void CrashExtension(std::string extension_id) {
+ void CrashExtension(size_t index) {
+ ASSERT_LT(index, GetExtensionService()->extensions()->size());
const Extension* extension =
- GetExtensionService()->extensions()->GetByID(extension_id);
+ GetExtensionService()->extensions()->at(index);
ASSERT_TRUE(extension);
+ std::string extension_id(extension->id());
ExtensionHost* extension_host = GetExtensionProcessManager()->
GetBackgroundHostForExtension(extension_id);
ASSERT_TRUE(extension_host);
@@ -79,36 +81,43 @@
GetBackgroundHostForExtension(extension_id));
}
- void CheckExtensionConsistency(std::string extension_id) {
+ void CheckExtensionConsistency(size_t index) {
+ ASSERT_LT(index, GetExtensionService()->extensions()->size());
const Extension* extension =
- GetExtensionService()->extensions()->GetByID(extension_id);
+ GetExtensionService()->extensions()->at(index);
ASSERT_TRUE(extension);
ExtensionHost* extension_host = GetExtensionProcessManager()->
- GetBackgroundHostForExtension(extension_id);
+ GetBackgroundHostForExtension(extension->id());
ASSERT_TRUE(extension_host);
ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host));
ASSERT_TRUE(extension_host->IsRenderViewLive());
extensions::ProcessMap* process_map =
browser()->profile()->GetExtensionService()->process_map();
ASSERT_TRUE(process_map->Contains(
- extension_id, extension_host->render_view_host()->process()->GetID()));
+ extension->id(), extension_host->render_view_host()->process()->
+ GetID()));
}
void LoadTestExtension() {
ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
- const Extension* extension = LoadExtension(
- test_data_dir_.AppendASCII("common").AppendASCII("background_page"));
+ const size_t size_before = GetExtensionService()->extensions()->size();
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
+ const Extension* extension = GetExtensionService()->extensions()->back();
ASSERT_TRUE(extension);
first_extension_id_ = extension->id();
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
}
void LoadSecondExtension() {
- const Extension* extension = LoadExtension(
- test_data_dir_.AppendASCII("install").AppendASCII("install"));
+ int offset = GetExtensionService()->extensions()->size();
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("install").AppendASCII("install")));
+ const Extension* extension =
+ GetExtensionService()->extensions()->at(offset);
ASSERT_TRUE(extension);
second_extension_id_ = extension->id();
- CheckExtensionConsistency(second_extension_id_);
+ CheckExtensionConsistency(offset);
}
std::string first_extension_id_;
@@ -120,14 +129,14 @@
const size_t crash_size_before =
GetExtensionService()->terminated_extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 1,
GetExtensionService()->terminated_extensions()->size());
AcceptNotification(0);
SCOPED_TRACE("after clicking the balloon");
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
ASSERT_EQ(crash_size_before,
GetExtensionService()->terminated_extensions()->size());
}
@@ -137,7 +146,7 @@
const size_t crash_size_before =
GetExtensionService()->terminated_extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 1,
@@ -147,7 +156,7 @@
ReloadExtension(first_extension_id_);
SCOPED_TRACE("after reloading");
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
ASSERT_EQ(crash_size_before,
GetExtensionService()->terminated_extensions()->size());
}
@@ -155,13 +164,13 @@
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, ReloadIndependently) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
ReloadExtension(first_extension_id_);
SCOPED_TRACE("after reloading");
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
TabContents* current_tab = browser()->GetSelectedTabContents();
ASSERT_TRUE(current_tab);
@@ -175,7 +184,7 @@
ReloadIndependentlyChangeTabs) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
TabContents* original_tab = browser()->GetSelectedTabContents();
@@ -192,7 +201,7 @@
ReloadExtension(first_extension_id_);
SCOPED_TRACE("after reloading");
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
// The balloon should automatically hide after the extension is successfully
// reloaded.
@@ -203,7 +212,7 @@
ReloadIndependentlyNavigatePage) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
TabContents* current_tab = browser()->GetSelectedTabContents();
@@ -219,7 +228,7 @@
ReloadExtension(first_extension_id_);
SCOPED_TRACE("after reloading");
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
// The balloon should automatically hide after the extension is successfully
// reloaded.
@@ -240,7 +249,7 @@
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, MAYBE_ShutdownWhileCrashed) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
}
@@ -248,26 +257,26 @@
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
AcceptNotification(0);
SCOPED_TRACE("after clicking the balloon");
- CheckExtensionConsistency(first_extension_id_);
- CheckExtensionConsistency(second_extension_id_);
+ CheckExtensionConsistency(size_before);
+ CheckExtensionConsistency(size_before + 1);
}
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsCrashSecond) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(second_extension_id_);
+ CrashExtension(size_before + 1);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
AcceptNotification(0);
SCOPED_TRACE("after clicking the balloon");
- CheckExtensionConsistency(first_extension_id_);
- CheckExtensionConsistency(second_extension_id_);
+ CheckExtensionConsistency(size_before);
+ CheckExtensionConsistency(size_before + 1);
}
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
@@ -277,11 +286,11 @@
GetExtensionService()->terminated_extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 1,
GetExtensionService()->terminated_extensions()->size());
- CrashExtension(second_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 2,
GetExtensionService()->terminated_extensions()->size());
@@ -289,37 +298,37 @@
{
SCOPED_TRACE("first balloon");
AcceptNotification(0);
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
}
{
SCOPED_TRACE("second balloon");
AcceptNotification(0);
- CheckExtensionConsistency(first_extension_id_);
- CheckExtensionConsistency(second_extension_id_);
+ CheckExtensionConsistency(size_before);
+ CheckExtensionConsistency(size_before + 1);
}
}
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsOneByOne) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
LoadSecondExtension();
- CrashExtension(second_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
{
SCOPED_TRACE("first balloon");
AcceptNotification(0);
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
}
{
SCOPED_TRACE("second balloon");
AcceptNotification(0);
- CheckExtensionConsistency(first_extension_id_);
- CheckExtensionConsistency(second_extension_id_);
+ CheckExtensionConsistency(size_before);
+ CheckExtensionConsistency(size_before + 1);
}
}
@@ -339,10 +348,10 @@
MAYBE_TwoExtensionsShutdownWhileCrashed) {
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
LoadSecondExtension();
- CrashExtension(second_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
}
@@ -351,9 +360,9 @@
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
- CrashExtension(second_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
// Accept notification 1 before canceling notification 0.
@@ -364,7 +373,9 @@
SCOPED_TRACE("balloons done");
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
- CheckExtensionConsistency(second_extension_id_);
+ EXPECT_EQ(second_extension_id_,
+ GetExtensionService()->extensions()->at(size_before)->id());
+ CheckExtensionConsistency(size_before);
}
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
@@ -372,9 +383,9 @@
const size_t size_before = GetExtensionService()->extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
- CrashExtension(second_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
{
@@ -386,14 +397,14 @@
ReloadExtension(first_extension_id_);
// One of the balloons should hide after the extension is reloaded.
ASSERT_EQ(1U, CountBalloons());
- CheckExtensionConsistency(first_extension_id_);
+ CheckExtensionConsistency(size_before);
}
{
SCOPED_TRACE("second: balloon");
AcceptNotification(0);
- CheckExtensionConsistency(first_extension_id_);
- CheckExtensionConsistency(second_extension_id_);
+ CheckExtensionConsistency(size_before);
+ CheckExtensionConsistency(size_before + 1);
}
}
@@ -403,7 +414,7 @@
GetExtensionService()->terminated_extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 1,
GetExtensionService()->terminated_extensions()->size());
@@ -432,7 +443,7 @@
GetExtensionService()->terminated_extensions()->size();
LoadTestExtension();
LoadSecondExtension();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 1,
GetExtensionService()->terminated_extensions()->size());
@@ -460,7 +471,7 @@
GURL("chrome-extension://" + first_extension_id_ + "/background.html"));
const int tabs_before = tab_strip->count();
- CrashExtension(first_extension_id_);
+ CrashExtension(size_before);
// Tab should still be open, and extension should be crashed.
EXPECT_EQ(tabs_before, tab_strip->count());
@@ -477,8 +488,6 @@
observer.Wait();
}
// Extension should now be loaded.
- SCOPED_TRACE("after reloading the tab");
- CheckExtensionConsistency(first_extension_id_);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
ASSERT_EQ(0U, CountBalloons());
}
Property changes on: chrome/browser/extensions/extension_crash_recovery_browsertest.cc
___________________________________________________________________
Added: svn:mergeinfo

Powered by Google App Engine
This is Rietveld 408576698