| 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_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_
H_ | 5 #ifndef CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_
H_ |
| 6 #define CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_
H_ | 6 #define CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UTIL_
H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 13 #include "chrome/browser/ui/permission_bubble/permission_prompt.h" | 13 #include "chrome/browser/ui/permission_bubble/permission_prompt.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class CommandLine; | 16 class CommandLine; |
| 17 } | 17 } |
| 18 class PermissionRequest; | 18 class PermissionRequest; |
| 19 class Browser; | 19 class Browser; |
| 20 | 20 |
| 21 class TestPermissionBubbleViewDelegate : public PermissionPrompt::Delegate { | 21 class TestPermissionBubbleViewDelegate : public PermissionPrompt::Delegate { |
| 22 public: | 22 public: |
| 23 TestPermissionBubbleViewDelegate(); | 23 TestPermissionBubbleViewDelegate(); |
| 24 ~TestPermissionBubbleViewDelegate() override; | 24 ~TestPermissionBubbleViewDelegate() override; |
| 25 | 25 |
| 26 const std::vector<PermissionRequest*>& Requests() override; | 26 const std::vector<PermissionRequest*>& Requests() override; |
| 27 const std::vector<bool>& AcceptStates() override; | |
| 28 | 27 |
| 29 void ToggleAccept(int, bool) override {} | |
| 30 void TogglePersist(bool) override {} | 28 void TogglePersist(bool) override {} |
| 31 void Accept() override {} | 29 void Accept() override {} |
| 32 void Deny() override {} | 30 void Deny() override {} |
| 33 void Closing() override {} | 31 void Closing() override {} |
| 34 | 32 |
| 35 void set_requests(std::vector<PermissionRequest*> requests) { | 33 void set_requests(std::vector<PermissionRequest*> requests) { |
| 36 requests_ = requests; | 34 requests_ = requests; |
| 37 } | 35 } |
| 38 | 36 |
| 39 private: | 37 private: |
| 40 std::vector<PermissionRequest*> requests_; | 38 std::vector<PermissionRequest*> requests_; |
| 41 std::vector<bool> accept_states_; | |
| 42 | 39 |
| 43 DISALLOW_COPY_AND_ASSIGN(TestPermissionBubbleViewDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(TestPermissionBubbleViewDelegate); |
| 44 }; | 41 }; |
| 45 | 42 |
| 46 // Use this class to test on a default window or an app window. Inheriting from | 43 // Use this class to test on a default window or an app window. Inheriting from |
| 47 // ExtensionBrowserTest allows us to easily load and launch apps, and doesn't | 44 // ExtensionBrowserTest allows us to easily load and launch apps, and doesn't |
| 48 // really add any extra work. | 45 // really add any extra work. |
| 49 class PermissionBubbleBrowserTest : public ExtensionBrowserTest { | 46 class PermissionBubbleBrowserTest : public ExtensionBrowserTest { |
| 50 public: | 47 public: |
| 51 PermissionBubbleBrowserTest(); | 48 PermissionBubbleBrowserTest(); |
| 52 ~PermissionBubbleBrowserTest() override; | 49 ~PermissionBubbleBrowserTest() override; |
| 53 | 50 |
| 54 void SetUpOnMainThread() override; | 51 void SetUpOnMainThread() override; |
| 55 | 52 |
| 56 // Opens an app window, and returns the associated browser. | 53 // Opens an app window, and returns the associated browser. |
| 57 Browser* OpenExtensionAppWindow(); | 54 Browser* OpenExtensionAppWindow(); |
| 58 | 55 |
| 59 PermissionPrompt::Delegate* test_delegate() { return &test_delegate_; } | 56 PermissionPrompt::Delegate* test_delegate() { return &test_delegate_; } |
| 60 | 57 |
| 61 private: | 58 private: |
| 62 TestPermissionBubbleViewDelegate test_delegate_; | 59 TestPermissionBubbleViewDelegate test_delegate_; |
| 63 std::vector<std::unique_ptr<PermissionRequest>> requests_; | 60 std::vector<std::unique_ptr<PermissionRequest>> requests_; |
| 64 std::vector<bool> accept_states_; | |
| 65 | 61 |
| 66 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleBrowserTest); | 62 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleBrowserTest); |
| 67 }; | 63 }; |
| 68 | 64 |
| 69 // Use this class to test on a kiosk window. | 65 // Use this class to test on a kiosk window. |
| 70 class PermissionBubbleKioskBrowserTest : public PermissionBubbleBrowserTest { | 66 class PermissionBubbleKioskBrowserTest : public PermissionBubbleBrowserTest { |
| 71 public: | 67 public: |
| 72 PermissionBubbleKioskBrowserTest(); | 68 PermissionBubbleKioskBrowserTest(); |
| 73 ~PermissionBubbleKioskBrowserTest() override; | 69 ~PermissionBubbleKioskBrowserTest() override; |
| 74 | 70 |
| 75 void SetUpCommandLine(base::CommandLine* command_line) override; | 71 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 76 | 72 |
| 77 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleKioskBrowserTest); | 73 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleKioskBrowserTest); |
| 78 }; | 74 }; |
| 79 | 75 |
| 80 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UT
IL_H_ | 76 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UT
IL_H_ |
| OLD | NEW |