| 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_UI_WEBSITE_SETTINGS_MOCK_PERMISSION_BUBBLE_FACTORY_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_MOCK_PERMISSION_BUBBLE_FACTORY_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "chrome/browser/permissions/permission_request_manager.h" | |
| 12 | |
| 13 class Browser; | |
| 14 class PermissionBubbleView; | |
| 15 class MockPermissionBubbleView; | |
| 16 | |
| 17 // Provides a skeleton class for both unit and browser testing when trying to | |
| 18 // test the bubble manager logic. Should not be used for anything that requires | |
| 19 // actual UI. | |
| 20 // See example usage in | |
| 21 // chrome/browser/permissions/permission_request_manager_unittest.cc | |
| 22 class MockPermissionBubbleFactory { | |
| 23 public: | |
| 24 explicit MockPermissionBubbleFactory(PermissionRequestManager* manager); | |
| 25 ~MockPermissionBubbleFactory(); | |
| 26 | |
| 27 // Create method called by the PBM to show a bubble. | |
| 28 std::unique_ptr<PermissionBubbleView> Create(Browser* browser); | |
| 29 | |
| 30 void SetCanUpdateUi(bool can_update_ui); | |
| 31 | |
| 32 void ResetCounts(); | |
| 33 | |
| 34 void DocumentOnLoadCompletedInMainFrame(); | |
| 35 | |
| 36 void set_response_type(PermissionRequestManager::AutoResponseType type) { | |
| 37 response_type_ = type; | |
| 38 } | |
| 39 | |
| 40 // If the current view is visible. | |
| 41 bool is_visible(); | |
| 42 // Number of times |Show| was called on any bubble. | |
| 43 int show_count() { return show_count_; } | |
| 44 // Number of requests seen by the last |Show|. | |
| 45 int request_count() { return requests_count_; } | |
| 46 // Number of requests seen. | |
| 47 int total_request_count() { return total_requests_count_; } | |
| 48 | |
| 49 void WaitForPermissionBubble(); | |
| 50 | |
| 51 private: | |
| 52 friend class MockPermissionBubbleView; | |
| 53 | |
| 54 // This shouldn't be called. Is here to fail tests that try to create a bubble | |
| 55 // after the factory has been destroyed. | |
| 56 static std::unique_ptr<PermissionBubbleView> DoNotCreate(Browser* browser); | |
| 57 | |
| 58 void UpdateResponseType(); | |
| 59 void ShowView(MockPermissionBubbleView* view); | |
| 60 void HideView(MockPermissionBubbleView* view); | |
| 61 | |
| 62 bool can_update_ui_; | |
| 63 int show_count_; | |
| 64 int requests_count_; | |
| 65 int total_requests_count_; | |
| 66 std::vector<MockPermissionBubbleView*> views_; | |
| 67 PermissionRequestManager::AutoResponseType response_type_; | |
| 68 | |
| 69 base::Closure show_bubble_quit_closure_; | |
| 70 | |
| 71 // The bubble manager that will be associated with this factory. | |
| 72 PermissionRequestManager* manager_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(MockPermissionBubbleFactory); | |
| 75 }; | |
| 76 | |
| 77 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_MOCK_PERMISSION_BUBBLE_FACTORY_H_ | |
| OLD | NEW |