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

Unified Diff: chrome/browser/background/background_application_list_model_unittest.cc

Issue 10298002: No longer start BG mode until a BackgroundContents is loaded (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests. Created 8 years, 8 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
Index: chrome/browser/background/background_application_list_model_unittest.cc
diff --git a/chrome/browser/background/background_application_list_model_unittest.cc b/chrome/browser/background/background_application_list_model_unittest.cc
index 2e8690ec3f37da2bdf953c610e5be0fb355b0c7b..30efc20765f5f301daf492bd75d9be8c66d0b9d4 100644
--- a/chrome/browser/background/background_application_list_model_unittest.cc
+++ b/chrome/browser/background/background_application_list_model_unittest.cc
@@ -84,7 +84,10 @@ std::string GenerateUniqueExtensionName() {
void AddBackgroundPermission(ExtensionService* service,
Extension* extension) {
- if (BackgroundApplicationListModel::IsBackgroundApp(*extension)) return;
+ if (BackgroundApplicationListModel::IsBackgroundApp(*extension,
Mihai Parparita -not on Chrome 2012/05/03 00:54:11 Nit: You may want to make this into a IsBackground
Andrew T Wilson (Slow) 2012/05/03 07:42:56 Done.
+ service->profile())) {
+ return;
+ }
static scoped_refptr<Extension> temporary =
CreateExtension(GenerateUniqueExtensionName(), true);
@@ -96,7 +99,10 @@ void AddBackgroundPermission(ExtensionService* service,
void RemoveBackgroundPermission(ExtensionService* service,
Extension* extension) {
- if (!BackgroundApplicationListModel::IsBackgroundApp(*extension)) return;
+ if (!BackgroundApplicationListModel::IsBackgroundApp(*extension,
+ service->profile())) {
+ return;
+ }
extensions::PermissionsUpdater(service->profile()).RemovePermissions(
extension, extension->GetActivePermissions());
}
@@ -125,45 +131,55 @@ TEST_F(BackgroundApplicationListModelTest, ExplicitTest) {
ASSERT_EQ(0U, model->size());
// Add alternating Extensions and Background Apps
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext1));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext1,
+ profile_.get()));
service->AddExtension(ext1);
ASSERT_EQ(1U, service->extensions()->size());
ASSERT_EQ(0U, model->size());
- ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp1));
+ ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp1,
+ profile_.get()));
service->AddExtension(bgapp1);
ASSERT_EQ(2U, service->extensions()->size());
ASSERT_EQ(1U, model->size());
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext2));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext2,
+ profile_.get()));
service->AddExtension(ext2);
ASSERT_EQ(3U, service->extensions()->size());
ASSERT_EQ(1U, model->size());
- ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp2));
+ ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp2,
+ profile_.get()));
service->AddExtension(bgapp2);
ASSERT_EQ(4U, service->extensions()->size());
ASSERT_EQ(2U, model->size());
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext3));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext3,
+ profile_.get()));
service->AddExtension(ext3);
ASSERT_EQ(5U, service->extensions()->size());
ASSERT_EQ(2U, model->size());
// Remove in FIFO order.
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext1));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext1,
+ profile_.get()));
service->UninstallExtension(ext1->id(), false, NULL);
ASSERT_EQ(4U, service->extensions()->size());
ASSERT_EQ(2U, model->size());
- ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp1));
+ ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp1,
+ profile_.get()));
service->UninstallExtension(bgapp1->id(), false, NULL);
ASSERT_EQ(3U, service->extensions()->size());
ASSERT_EQ(1U, model->size());
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext2));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext2,
+ profile_.get()));
service->UninstallExtension(ext2->id(), false, NULL);
ASSERT_EQ(2U, service->extensions()->size());
ASSERT_EQ(1U, model->size());
- ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp2));
+ ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp2,
+ profile_.get()));
service->UninstallExtension(bgapp2->id(), false, NULL);
ASSERT_EQ(1U, service->extensions()->size());
ASSERT_EQ(0U, model->size());
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext3));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext3,
+ profile_.get()));
service->UninstallExtension(ext3->id(), false, NULL);
ASSERT_EQ(0U, service->extensions()->size());
ASSERT_EQ(0U, model->size());
@@ -188,11 +204,13 @@ TEST_F(BackgroundApplicationListModelTest, AddRemovePermissionsTest) {
ASSERT_EQ(0U, model->size());
// Add one (non-background) extension and one background application
- ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext));
+ ASSERT_FALSE(BackgroundApplicationListModel::IsBackgroundApp(*ext,
+ profile_.get()));
service->AddExtension(ext);
ASSERT_EQ(1U, service->extensions()->size());
ASSERT_EQ(0U, model->size());
- ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp));
+ ASSERT_TRUE(BackgroundApplicationListModel::IsBackgroundApp(*bgapp,
+ profile_.get()));
service->AddExtension(bgapp);
ASSERT_EQ(2U, service->extensions()->size());
ASSERT_EQ(1U, model->size());
@@ -227,7 +245,8 @@ void AddExtension(ExtensionService* service,
}
scoped_refptr<Extension> extension =
CreateExtension(GenerateUniqueExtensionName(), create_background);
- ASSERT_EQ(BackgroundApplicationListModel::IsBackgroundApp(*extension),
+ ASSERT_EQ(BackgroundApplicationListModel::IsBackgroundApp(*extension,
+ service->profile()),
create_background);
extensions->insert(extension);
++*count;
@@ -258,8 +277,10 @@ void RemoveExtension(ExtensionService* service,
}
scoped_refptr<Extension> extension = cursor->get();
std::string id = extension->id();
- if (BackgroundApplicationListModel::IsBackgroundApp(*extension))
+ if (BackgroundApplicationListModel::IsBackgroundApp(*extension,
+ service->profile())) {
--*expected;
+ }
extensions->erase(cursor);
--*count;
ASSERT_EQ(*count, extensions->size());
@@ -290,7 +311,8 @@ void TogglePermission(ExtensionService* service,
}
scoped_refptr<Extension> extension = cursor->get();
std::string id = extension->id();
- if (BackgroundApplicationListModel::IsBackgroundApp(*extension)) {
+ if (BackgroundApplicationListModel::IsBackgroundApp(*extension,
+ service->profile())) {
--*expected;
ASSERT_EQ(*count, extensions->size());
RemoveBackgroundPermission(service, extension);

Powered by Google App Engine
This is Rietveld 408576698