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

Side by Side Diff: chrome/browser/permissions/permissions_browsertest.h

Issue 2361453004: Add browsertest for Flash permission prompt (Closed)
Patch Set: Test Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSIONS_BROWSERTEST_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSIONS_BROWSERTEST_H_
7
8 #include <string>
9
10 #include "chrome/test/base/in_process_browser_test.h"
11
12 namespace content {
13 class WebContents;
14 } // namespace content
15
16 class MockPermissionPromptFactory;
17
18 // This is a base class for end-to-end testing of features that have
19 // permissions. It will navigate to the URL passed in upon construction, ready
20 // to execute javascript to test the permissions. There are also a set of common
21 // tests functions that are provided (see the functions with the Common*
dominickn 2016/09/29 03:08:48 Nit: "test functions"
raymes 2016/09/29 04:12:45 Done.
22 // prefix). These should be called to ensure basic test coverage of the
23 // feature's permission that is being added. Custom tests can also be added
24 // for the permission. For an example of how to use this base class, see
25 // FlashPermissionBrowserTest.
26 class PermissionsBrowserTest : public InProcessBrowserTest {
27 public:
28 explicit PermissionsBrowserTest(const std::string& test_url);
29 ~PermissionsBrowserTest() override;
30
31 // InProcessBrowserTest
32 void SetUpOnMainThread() override;
33 void TearDownOnMainThread() override;
34
35 virtual void TriggerPrompt() = 0;
36 virtual bool FeatureUsageSucceeds() = 0;
37
38 std::string test_url() const { return test_url_; }
39
40 MockPermissionPromptFactory* prompt_factory() {
41 return prompt_factory_.get();
42 }
43
44 protected:
45 bool RunScriptReturnBool(const std::string& script);
46
47 content::WebContents* GetWebContents();
48
49 // Common tests that should be called by subclasses.
50 void CommonFailsBeforeRequesting();
51 void CommonFailsIfDismissed();
52 void CommonFailsIfBlocked();
53 void CommonSucceedsIfAllowed();
54
55 private:
56 std::string test_url_;
57 std::unique_ptr<MockPermissionPromptFactory> prompt_factory_;
58 };
59
60 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSIONS_BROWSERTEST_H_
OLDNEW
« 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