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

Unified Diff: apps/load_and_launch_browsertest.cc

Issue 2108853002: Restrict use of two app-launching command line flags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a browsertest Created 4 years, 6 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: apps/load_and_launch_browsertest.cc
diff --git a/apps/load_and_launch_browsertest.cc b/apps/load_and_launch_browsertest.cc
index fc95daec61bc75a6fdd0be387e65942f9d00ab93..0043ce5e8ae6c7c58c234e560e6037ca202a608e 100644
--- a/apps/load_and_launch_browsertest.cc
+++ b/apps/load_and_launch_browsertest.cc
@@ -11,10 +11,13 @@
#include "base/test/test_timeouts.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/simple_message_box_internal.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/test_launcher.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/test/extension_test_message_listener.h"
using extensions::PlatformAppBrowserTest;
@@ -112,7 +115,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
namespace {
-// TestFixture that appends --load-and-launch-app before calling BrowserMain.
+// TestFixture that appends --load-and-launch-app with an app before calling
+// BrowserMain.
class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest {
protected:
PlatformAppLoadAndLaunchBrowserTest() {}
@@ -141,6 +145,36 @@ class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest {
DISALLOW_COPY_AND_ASSIGN(PlatformAppLoadAndLaunchBrowserTest);
};
+// TestFixture that appends --load-and-launch-app with an extension before
+// calling BrowserMain.
+class LoadAndLaunchExtensionBrowserTest : public PlatformAppBrowserTest {
+ protected:
+ LoadAndLaunchExtensionBrowserTest() {}
+
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ PlatformAppBrowserTest::SetUpCommandLine(command_line);
+ app_path_ = test_data_dir_.AppendASCII("good")
+ .AppendASCII("Extensions")
+ .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
+ .AppendASCII("1.0.0.0");
+ command_line->AppendSwitchNative(apps::kLoadAndLaunchApp,
+ app_path_.value());
+ }
+
+ void SetUpInProcessBrowserTestFixture() override {
+ PlatformAppBrowserTest::SetUpInProcessBrowserTestFixture();
+
+ // Skip showing the error message box in order to avoid freezing the main
+ // thread.
+ chrome::internal::g_should_skip_message_box_for_test = true;
+ }
+
+ private:
+ base::FilePath app_path_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoadAndLaunchExtensionBrowserTest);
+};
+
} // namespace
@@ -160,4 +194,19 @@ IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest,
LoadAndLaunchApp();
}
+IN_PROC_BROWSER_TEST_F(LoadAndLaunchExtensionBrowserTest,
+ LoadAndLaunchExtension) {
+ const std::vector<base::string16>* errors =
+ ExtensionErrorReporter::GetInstance()->GetErrors();
+
+ // Expect kUnpackedExtensionInsteadOfAppError.
+ EXPECT_EQ(1u, errors->size());
+
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile());
+ EXPECT_EQ(nullptr, registry->GetExtensionById(
+ "behllobkkfkfnphdnhnkndlbkcpglgmj",
+ extensions::ExtensionRegistry::EVERYTHING));
+}
+
} // namespace apps

Powered by Google App Engine
This is Rietveld 408576698