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

Unified Diff: chrome/browser/permissions/permissions_browsertest.h

Issue 2361453004: Add browsertest for Flash permission prompt (Closed)
Patch Set: Test Created 4 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
Index: chrome/browser/permissions/permissions_browsertest.h
diff --git a/chrome/browser/permissions/permissions_browsertest.h b/chrome/browser/permissions/permissions_browsertest.h
new file mode 100644
index 0000000000000000000000000000000000000000..15f2e243f4cd37937d78d83f76661d92ce6beecf
--- /dev/null
+++ b/chrome/browser/permissions/permissions_browsertest.h
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSIONS_BROWSERTEST_H_
+#define CHROME_BROWSER_PERMISSIONS_PERMISSIONS_BROWSERTEST_H_
+
+#include <string>
+
+#include "chrome/test/base/in_process_browser_test.h"
+
+namespace content {
+class WebContents;
+} // namespace content
+
+class MockPermissionPromptFactory;
+
+// This is a base class for end-to-end testing of features that have
+// permissions. It will navigate to the URL passed in upon construction, ready
+// to execute javascript to test the permissions. There are also a set of common
+// test functions that are provided (see the functions with the Common* prefix).
+// These should be called to ensure basic test coverage of the feature's
+// permission that is being added. Custom tests can also be added for the
+// permission. For an example of how to use this base class, see
+// FlashPermissionBrowserTest.
+class PermissionsBrowserTest : public InProcessBrowserTest {
+ public:
+ explicit PermissionsBrowserTest(const std::string& test_url);
+ ~PermissionsBrowserTest() override;
+
+ // InProcessBrowserTest
+ void SetUpOnMainThread() override;
+ void TearDownOnMainThread() override;
+
+ virtual void TriggerPrompt() = 0;
+ virtual bool FeatureUsageSucceeds() = 0;
+
+ std::string test_url() const { return test_url_; }
+
+ MockPermissionPromptFactory* prompt_factory() {
+ return prompt_factory_.get();
+ }
+
+ protected:
+ bool RunScriptReturnBool(const std::string& script);
+
+ content::WebContents* GetWebContents();
+
+ // Common tests that should be called by subclasses.
+ void CommonFailsBeforeRequesting();
+ void CommonFailsIfDismissed();
+ void CommonFailsIfBlocked();
+ void CommonSucceedsIfAllowed();
+
+ private:
+ std::string test_url_;
+ std::unique_ptr<MockPermissionPromptFactory> prompt_factory_;
+};
+
+#endif // CHROME_BROWSER_PERMISSIONS_PERMISSIONS_BROWSERTEST_H_
« no previous file with comments | « chrome/browser/engagement/site_engagement_score.h ('k') | chrome/browser/permissions/permissions_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698