| OLD | NEW |
| (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 // test functions that are provided (see the functions with the Common* prefix). |
| 22 // These should be called to ensure basic test coverage of the feature's |
| 23 // permission that is being added. Custom tests can also be added for the |
| 24 // 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_ |
| OLD | NEW |