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

Side by Side Diff: chrome/browser/ui/permission_bubble/permission_bubble_browser_test_util.h

Issue 2868783002: Move requests from Show() argument to PermissionPrompt::Delegate (Closed)
Patch Set: rm vector on android Created 3 years, 7 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
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;
25
26 const std::vector<PermissionRequest*>& Requests() override;
27 const std::vector<bool>& AcceptStates() override;
24 28
25 void ToggleAccept(int, bool) override {} 29 void ToggleAccept(int, bool) override {}
26 void TogglePersist(bool) override {} 30 void TogglePersist(bool) override {}
27 void Accept() override {} 31 void Accept() override {}
28 void Deny() override {} 32 void Deny() override {}
29 void Closing() override {} 33 void Closing() override {}
30 34
35 void SetRequests(std::vector<PermissionRequest*> requests) {
raymes 2017/05/11 01:17:54 nit: set_requests
Timothy Loh 2017/05/11 04:42:08 Done.
36 requests_ = requests;
37 }
38
31 private: 39 private:
40 std::vector<PermissionRequest*> requests_;
41 std::vector<bool> accept_states_;
42
32 DISALLOW_COPY_AND_ASSIGN(TestPermissionBubbleViewDelegate); 43 DISALLOW_COPY_AND_ASSIGN(TestPermissionBubbleViewDelegate);
33 }; 44 };
34 45
35 // Use this class to test on a default window or an app window. Inheriting from 46 // Use this class to test on a default window or an app window. Inheriting from
36 // ExtensionBrowserTest allows us to easily load and launch apps, and doesn't 47 // ExtensionBrowserTest allows us to easily load and launch apps, and doesn't
37 // really add any extra work. 48 // really add any extra work.
38 class PermissionBubbleBrowserTest : public ExtensionBrowserTest { 49 class PermissionBubbleBrowserTest : public ExtensionBrowserTest {
39 public: 50 public:
40 PermissionBubbleBrowserTest(); 51 PermissionBubbleBrowserTest();
41 ~PermissionBubbleBrowserTest() override; 52 ~PermissionBubbleBrowserTest() override;
42 53
43 void SetUpOnMainThread() override; 54 void SetUpOnMainThread() override;
44 55
45 // Opens an app window, and returns the associated browser. 56 // Opens an app window, and returns the associated browser.
46 Browser* OpenExtensionAppWindow(); 57 Browser* OpenExtensionAppWindow();
47 58
48 std::vector<PermissionRequest*> requests();
49 std::vector<bool> accept_states() { return accept_states_; }
50 PermissionPrompt::Delegate* test_delegate() { return &test_delegate_; } 59 PermissionPrompt::Delegate* test_delegate() { return &test_delegate_; }
51 60
52 private: 61 private:
62 std::vector<PermissionRequest*> requests();
raymes 2017/05/11 01:17:54 nit: no ()
Timothy Loh 2017/05/11 04:42:08 It's a function... anyway I reworked it a bit (inl
63
53 TestPermissionBubbleViewDelegate test_delegate_; 64 TestPermissionBubbleViewDelegate test_delegate_;
54 std::vector<std::unique_ptr<PermissionRequest>> requests_; 65 std::vector<std::unique_ptr<PermissionRequest>> requests_;
55 std::vector<bool> accept_states_; 66 std::vector<bool> accept_states_;
56 67
57 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleBrowserTest); 68 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleBrowserTest);
58 }; 69 };
59 70
60 // Use this class to test on a kiosk window. 71 // Use this class to test on a kiosk window.
61 class PermissionBubbleKioskBrowserTest : public PermissionBubbleBrowserTest { 72 class PermissionBubbleKioskBrowserTest : public PermissionBubbleBrowserTest {
62 public: 73 public:
63 PermissionBubbleKioskBrowserTest(); 74 PermissionBubbleKioskBrowserTest();
64 ~PermissionBubbleKioskBrowserTest() override; 75 ~PermissionBubbleKioskBrowserTest() override;
65 76
66 void SetUpCommandLine(base::CommandLine* command_line) override; 77 void SetUpCommandLine(base::CommandLine* command_line) override;
67 78
68 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleKioskBrowserTest); 79 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleKioskBrowserTest);
69 }; 80 };
70 81
71 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UT IL_H_ 82 #endif // CHROME_BROWSER_UI_PERMISSION_BUBBLE_PERMISSION_BUBBLE_BROWSER_TEST_UT IL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698