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

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

Issue 10907104: Support an --install-from-webstore command line switch (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebased Created 8 years, 3 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/extensions/tab_helper.cc ('k') | chrome/browser/extensions/webstore_inline_installer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/webstore_inline_install_browsertest.cc
diff --git a/chrome/browser/extensions/webstore_inline_install_browsertest.cc b/chrome/browser/extensions/webstore_inline_install_browsertest.cc
index becb99dba97cac85ee6760495d440697872b7328..737ce5bf45499c62dab6985ab023e10862a7dfee 100644
--- a/chrome/browser/extensions/webstore_inline_install_browsertest.cc
+++ b/chrome/browser/extensions/webstore_inline_install_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/extensions/extension_install_dialog.h"
#include "chrome/browser/extensions/extension_install_ui.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/startup_helper.h"
#include "chrome/browser/extensions/webstore_inline_installer.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
@@ -17,6 +18,8 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
@@ -25,10 +28,12 @@
#include "net/base/mock_host_resolver.h"
using content::WebContents;
+using extensions::Extension;
const char kWebstoreDomain[] = "cws.com";
const char kAppDomain[] = "app.com";
const char kNonAppDomain[] = "nonapp.com";
+const char kTestExtensionId[] = "ecglahbcnmdpdciemllbhojghbkagdje";
class WebstoreInlineInstallTest : public InProcessBrowserTest {
public:
@@ -93,8 +98,7 @@ IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) {
RunInlineInstallTest("runTest");
const extensions::Extension* extension = browser()->profile()->
- GetExtensionService()->GetExtensionById(
- "ecglahbcnmdpdciemllbhojghbkagdje", false);
+ GetExtensionService()->GetExtensionById(kTestExtensionId, false);
EXPECT_TRUE(extension);
}
@@ -174,3 +178,55 @@ IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest,
RunInlineInstallTest("runTest");
}
+
+class CommandLineWebstoreInstall : public WebstoreInlineInstallTest,
+ public content::NotificationObserver {
+ public:
+ CommandLineWebstoreInstall() : saw_install_(false) {}
+ virtual ~CommandLineWebstoreInstall() {}
+
+ virtual void SetUpOnMainThread() OVERRIDE {
+ WebstoreInlineInstallTest::SetUpOnMainThread();
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
+ content::NotificationService::AllSources());
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kInstallFromWebstore, kTestExtensionId);
+ }
+
+ bool saw_install() { return saw_install_; }
+
+ protected:
+ // NotificationObserver interface.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE {
+ ASSERT_EQ(chrome::NOTIFICATION_EXTENSION_INSTALLED, type);
+ const Extension* extension = content::Details<Extension>(details).ptr();
+ ASSERT_TRUE(extension != NULL);
+ EXPECT_EQ(extension->id(), kTestExtensionId);
+ saw_install_ = true;
+ }
+
+ content::NotificationRegistrar registrar_;
+
+ // Have we seen an installation notification for kTestExtensionId ?
+ bool saw_install_;
+};
+
+IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Accept) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ command_line->AppendSwitchASCII(
+ switches::kAppsGalleryInstallAutoConfirmForTests, "accept");
+ extensions::StartupHelper helper;
+ EXPECT_TRUE(helper.InstallFromWebstore(*command_line, browser()->profile()));
+ EXPECT_TRUE(saw_install());
+}
+
+IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Cancel) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ command_line->AppendSwitchASCII(
+ switches::kAppsGalleryInstallAutoConfirmForTests, "cancel");
+ extensions::StartupHelper helper;
+ EXPECT_FALSE(helper.InstallFromWebstore(*command_line, browser()->profile()));
+ EXPECT_FALSE(saw_install());
+}
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/browser/extensions/webstore_inline_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698