| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_H
_ | 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_H
_ |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_H
_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_H
_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" | 9 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 class CommandLine; | 12 class CommandLine; |
| 13 } | 13 } |
| 14 class PermissionBubbleRequest; | 14 class PermissionBubbleRequest; |
| 15 class Browser; | 15 class Browser; |
| 16 | 16 |
| 17 class TestPermissionBubbleViewDelegate : public PermissionBubbleView::Delegate { | 17 class TestPermissionBubbleViewDelegate : public PermissionBubbleView::Delegate { |
| 18 public: | 18 public: |
| 19 TestPermissionBubbleViewDelegate(); | 19 TestPermissionBubbleViewDelegate(); |
| 20 | 20 |
| 21 void ToggleAccept(int, bool) override {} | 21 void ToggleAccept(int, bool) override {} |
| 22 void Accept() override {} | 22 void Accept() override {} |
| 23 void Deny() override {} | 23 void Deny() override {} |
| 24 void Closing() override {} | 24 void Closing() override {} |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 DISALLOW_COPY_AND_ASSIGN(TestPermissionBubbleViewDelegate); | 27 DISALLOW_COPY_AND_ASSIGN(TestPermissionBubbleViewDelegate); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // Use this class to test on a default window. | 30 // Use this class to test on a default window or an app window. Inheriting from |
| 31 class PermissionBubbleBrowserTest : public virtual InProcessBrowserTest { | 31 // ExtensionBrowserTest allows us to easily load and launch apps, and doesn't |
| 32 // really add any extra work. |
| 33 class PermissionBubbleBrowserTest : public ExtensionBrowserTest { |
| 32 public: | 34 public: |
| 33 PermissionBubbleBrowserTest(); | 35 PermissionBubbleBrowserTest(); |
| 34 ~PermissionBubbleBrowserTest() override; | 36 ~PermissionBubbleBrowserTest() override; |
| 35 | 37 |
| 36 void SetUpOnMainThread() override; | 38 void SetUpOnMainThread() override; |
| 37 | 39 |
| 40 // Opens an app window, and returns the associated browser. |
| 41 Browser* OpenExtensionAppWindow(); |
| 42 |
| 38 std::vector<PermissionBubbleRequest*> requests() { return requests_.get(); } | 43 std::vector<PermissionBubbleRequest*> requests() { return requests_.get(); } |
| 39 std::vector<bool> accept_states() { return accept_states_; } | 44 std::vector<bool> accept_states() { return accept_states_; } |
| 40 PermissionBubbleView::Delegate* test_delegate() { return &test_delegate_; } | 45 PermissionBubbleView::Delegate* test_delegate() { return &test_delegate_; } |
| 41 | 46 |
| 42 private: | 47 private: |
| 43 TestPermissionBubbleViewDelegate test_delegate_; | 48 TestPermissionBubbleViewDelegate test_delegate_; |
| 44 ScopedVector<PermissionBubbleRequest> requests_; | 49 ScopedVector<PermissionBubbleRequest> requests_; |
| 45 std::vector<bool> accept_states_; | 50 std::vector<bool> accept_states_; |
| 46 }; | |
| 47 | 51 |
| 48 // Use this class to test on an app window. | 52 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleBrowserTest); |
| 49 class PermissionBubbleAppBrowserTest : public PermissionBubbleBrowserTest, | |
| 50 public ExtensionBrowserTest { | |
| 51 public: | |
| 52 PermissionBubbleAppBrowserTest(); | |
| 53 ~PermissionBubbleAppBrowserTest() override; | |
| 54 | |
| 55 void SetUpOnMainThread() override; | |
| 56 | |
| 57 // Override from ExtensionBrowserTest to avoid "inheritance via dominance". | |
| 58 void SetUp() override; | |
| 59 void SetUpCommandLine(base::CommandLine* command_line) override; | |
| 60 | |
| 61 Browser* app_browser() { return app_browser_; } | |
| 62 | |
| 63 private: | |
| 64 Browser* app_browser_; | |
| 65 | |
| 66 Browser* OpenExtensionAppWindow(const extensions::Extension* extension); | |
| 67 }; | 53 }; |
| 68 | 54 |
| 69 // Use this class to test on a kiosk window. | 55 // Use this class to test on a kiosk window. |
| 70 class PermissionBubbleKioskBrowserTest : public PermissionBubbleBrowserTest { | 56 class PermissionBubbleKioskBrowserTest : public PermissionBubbleBrowserTest { |
| 71 public: | 57 public: |
| 72 PermissionBubbleKioskBrowserTest(); | 58 PermissionBubbleKioskBrowserTest(); |
| 73 ~PermissionBubbleKioskBrowserTest() override; | 59 ~PermissionBubbleKioskBrowserTest() override; |
| 74 | 60 |
| 75 void SetUpCommandLine(base::CommandLine* command_line) override; | 61 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleKioskBrowserTest); |
| 76 }; | 64 }; |
| 77 | 65 |
| 78 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_BROWSER_TEST_UTI
L_H_ | 66 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_BROWSER_TEST_UTI
L_H_ |
| OLD | NEW |