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

Unified Diff: chrome/renderer/chrome_content_renderer_client_browsertest.cc

Issue 300873002: Removed NPAPI plugin infobar, with Finch trial gate (disabled by default). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add browser_tests for infobar removal Created 6 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
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/chrome_content_renderer_client_browsertest.cc
diff --git a/chrome/renderer/chrome_content_renderer_client_browsertest.cc b/chrome/renderer/chrome_content_renderer_client_browsertest.cc
index 603d78e8f4c489d97f854dc53514a67c204d3139..4aff9af53d84270d42e85e0d67e6844c60e93af9 100644
--- a/chrome/renderer/chrome_content_renderer_client_browsertest.cc
+++ b/chrome/renderer/chrome_content_renderer_client_browsertest.cc
@@ -6,14 +6,32 @@
#include <vector>
+#include "base/bind.h"
#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/browser/net/url_request_mock_util.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/test/base/chrome_render_view_test.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/common/content_paths.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/test_utils.h"
+#include "content/test/net/url_request_mock_http_job.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "url/gurl.h"
+using content::BrowserThread;
+using content::URLRequestMockHTTPJob;
+
typedef ChromeRenderViewTest InstantProcessNavigationTest;
// Tests that renderer-initiated navigations from an Instant render process get
@@ -52,3 +70,108 @@ TEST_F(InstantProcessNavigationTest, ForkForNavigationsToSearchURLs) {
GetMainFrame(), GURL("http://example.com/"), "GET", false, false,
&unused));
}
+
+namespace {
+
+// Tests that when the UnauthorizedPluginInfoBar Finch trial is set to
+// Default behavior (disabled) should still be correctly tested when Finch trial
+// is over.
+// TODO(cthomp) Remove/simplify when Finch trial is completed
+class UnauthorizedPluginInfoBarBrowserTestBase : public InProcessBrowserTest {
+ public:
+ explicit UnauthorizedPluginInfoBarBrowserTestBase(
+ bool do_infobar_enabled_trial)
+ : do_infobar_enabled_trial_(do_infobar_enabled_trial) {}
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ if (do_infobar_enabled_trial_) {
+ command_line->AppendSwitchASCII(switches::kForceFieldTrials,
+ "UnauthorizedPluginInfoBar/Enabled/");
+ } else {
+ command_line->AppendSwitchASCII(switches::kForceFieldTrials,
+ "UnauthorizedPluginInfoBar/Disabled/");
+ }
+ }
+
+ // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA
+ // instead of chrome::DIR_TEST_DATA.
+ void ServeContentTestData() {
+ base::FilePath root_http;
+ PathService::Get(content::DIR_TEST_DATA, &root_http);
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(URLRequestMockHTTPJob::AddUrlHandler, root_http),
+ base::MessageLoop::current()->QuitWhenIdleClosure());
+ content::RunMessageLoop();
+ }
+
+ // Verifies that the test page exists (only present with src-internal)
+ bool TestPageExists() {
+ if (!base::PathExists(ui_test_utils::GetTestFilePath(
+ base::FilePath(FILE_PATH_LITERAL("plugin")),
+ base::FilePath(FILE_PATH_LITERAL("quicktime.html"))))) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ bool InfoBarCountTest(unsigned int number_infobars_expected,
+ Browser* browser) {
+ ServeContentTestData();
+ content::WebContents* contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ // ASSERT_TRUE(contents);
radhikabhar 2014/06/06 17:05:40 Do we need this comment out here?
Chris Thompson 2014/06/06 17:37:48 Uncommented and changed to EXPECT_TRUE (since thes
Bernhard Bauer 2014/06/09 17:03:18 FTR, ASSERT_ and EXPECT_ are not used to distingui
+ InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
+ // ASSERT_TRUE(infobar_service);
+ EXPECT_EQ(0u, infobar_service->infobar_count());
+
+ base::FilePath path(FILE_PATH_LITERAL("plugin/quicktime.html"));
+ GURL url(URLRequestMockHTTPJob::GetMockUrl(path));
+ ui_test_utils::NavigateToURL(browser, url);
+ // Compare to number of infobars expected
+ return (number_infobars_expected == infobar_service->infobar_count());
+ }
+
+ private:
+ bool do_infobar_enabled_trial_;
+ DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarBrowserTestBase);
+};
+
+class InfoBarEnabledBrowserTest :
+ public UnauthorizedPluginInfoBarBrowserTestBase {
+ public:
+ InfoBarEnabledBrowserTest() :
+ UnauthorizedPluginInfoBarBrowserTestBase(true) {}
+};
+
+class InfoBarDisabledBrowserTest :
+ public UnauthorizedPluginInfoBarBrowserTestBase {
+ public:
+ InfoBarDisabledBrowserTest() :
+ UnauthorizedPluginInfoBarBrowserTestBase(false) {}
+};
+
+// When "UnauthorizedPluginInfoBar" is "Enabled", infobar for NPAPI plugin
+// should be shown.
+IN_PROC_BROWSER_TEST_F(InfoBarEnabledBrowserTest, InfobarEnabled) {
+ if (!TestPageExists()) {
+ LOG(INFO) <<
+ "Test skipped because plugin/quicktime.html test file wasn't found.";
+ return;
+ }
+ ASSERT_TRUE(InfoBarCountTest(1u, browser()));
+}
+
+// When "UnauthorizedPluginInfoBar" is "Disabled", infobar for NPAPI plugin
+// should not be shown.
+IN_PROC_BROWSER_TEST_F(InfoBarDisabledBrowserTest, TestDisabled) {
+ if (!TestPageExists()) {
+ LOG(INFO) <<
+ "Test skipped because plugin/quicktime.html test file wasn't found.";
+ return;
+ }
+ ASSERT_TRUE(InfoBarCountTest(0u, browser()));
+}
+
+} // namespace
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698