Chromium Code Reviews| 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 { |
|
msw
2016/07/21 17:13:49
optional nit: LoadAndLaunchPlatformAppBrowserTest
proberge
2016/07/25 20:40:53
Done.
|
| 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") |
|
msw
2016/07/21 17:13:50
nit: not used elsewhere; make this function-local.
proberge
2016/07/25 20:40:53
Done.
|
| + .AppendASCII("Extensions") |
| + .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
|
msw
2016/07/21 17:13:50
nit: cache extension id string (file-local static?
proberge
2016/07/25 20:40:53
Done.
|
| + .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 |
|
msw
2016/07/21 17:13:50
optional nit: -'in order' for a one-liner
proberge
2016/07/25 20:40:53
Done.
|
| + // 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(); |
|
msw
2016/07/21 17:13:50
optional nit: check that the app actually loaded?
proberge
2016/07/25 20:40:53
Will do once the test is re-enabled.
|
| } |
| +IN_PROC_BROWSER_TEST_F(LoadAndLaunchExtensionBrowserTest, |
| + LoadAndLaunchExtension) { |
| + const std::vector<base::string16>* errors = |
| + ExtensionErrorReporter::GetInstance()->GetErrors(); |
| + |
| + // Expect kUnpackedExtensionInsteadOfAppError. |
|
msw
2016/07/21 17:13:49
nit: check for this value?
proberge
2016/07/25 20:40:53
Done.
|
| + EXPECT_EQ(1u, errors->size()); |
|
msw
2016/07/21 17:13:50
Does this ever run on official builds? If so, it'l
proberge
2016/07/25 20:40:53
Good catch! Thanks
|
| + |
| + extensions::ExtensionRegistry* registry = |
| + extensions::ExtensionRegistry::Get(profile()); |
| + EXPECT_EQ(nullptr, registry->GetExtensionById( |
| + "behllobkkfkfnphdnhnkndlbkcpglgmj", |
| + extensions::ExtensionRegistry::EVERYTHING)); |
| +} |
| + |
| } // namespace apps |