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

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

Issue 383113002: Ephemeral apps should not trigger Chrome background mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Add extra test for the balloon Created 6 years, 5 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 | « chrome/browser/background/background_application_list_model_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background/background_mode_manager_unittest.cc
diff --git a/chrome/browser/background/background_mode_manager_unittest.cc b/chrome/browser/background/background_mode_manager_unittest.cc
index 6f372cb80765ff9b6ba47056e407a524bb1d716a..ec0d27652db0f50b26808230df0276969305dc4f 100644
--- a/chrome/browser/background/background_mode_manager_unittest.cc
+++ b/chrome/browser/background/background_mode_manager_unittest.cc
@@ -19,6 +19,7 @@
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/image/image.h"
@@ -268,6 +269,20 @@ class BackgroundModeManagerWithExtensionsTest
protected:
scoped_ptr<SimpleTestBackgroundModeManager> manager_;
+ void AddEphemeralApp(const extensions::Extension* extension,
+ ExtensionService* service) {
+ extensions::ExtensionPrefs* prefs =
+ extensions::ExtensionPrefs::Get(service->profile());
+ ASSERT_TRUE(prefs);
+ prefs->OnExtensionInstalled(extension,
+ extensions::Extension::ENABLED,
+ syncer::StringOrdinal(),
+ extensions::kInstallFlagIsEphemeral,
+ std::string());
+
+ service->AddExtension(extension);
+ }
+
private:
// Required for extension service.
content::TestBrowserThreadBundle thread_bundle_;
@@ -818,6 +833,15 @@ TEST_F(BackgroundModeManagerWithExtensionsTest, BalloonDisplay) {
"\"permissions\": [\"background\"]}",
"ID-2"));
+ scoped_refptr<extensions::Extension> ephemeral_app(
+ CreateExtension(
+ extensions::Manifest::COMMAND_LINE,
+ "{\"name\": \"Ephemeral App\", "
+ "\"version\": \"1.0\","
+ "\"manifest_version\": 2,"
+ "\"permissions\": [\"pushMessaging\"]}",
+ "ID-3"));
+
static_cast<extensions::TestExtensionSystem*>(
extensions::ExtensionSystem::Get(profile_))->CreateExtensionService(
CommandLine::ForCurrentProcess(),
@@ -850,4 +874,14 @@ TEST_F(BackgroundModeManagerWithExtensionsTest, BalloonDisplay) {
// show the balloon.
service->AddExtension(upgraded_no_bg_ext_has_bg);
EXPECT_TRUE(manager_->HasShownBalloon());
+
+ // Installing an ephemeral app should not show the balloon.
+ manager_->SetHasShownBalloon(false);
+ AddEphemeralApp(ephemeral_app.get(), service);
+ EXPECT_FALSE(manager_->HasShownBalloon());
+
+ // Promoting the ephemeral app to a regular installed app should now show
+ // the balloon.
+ service->PromoteEphemeralApp(ephemeral_app.get(), false /*from sync*/);
+ EXPECT_TRUE(manager_->HasShownBalloon());
}
« no previous file with comments | « chrome/browser/background/background_application_list_model_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698