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

Side by Side Diff: chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h

Issue 888043003: [Extensions Toolbar Views] Add a ToolbarActionView unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TEST_TOOLBAR_ACTION_VIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TEST_TOOLBAR_ACTION_VIEW_CONTROLLER_H_
7
8 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
9
10 // A minimalistic and configurable ToolbarActionViewController for use in
11 // testing.
12 class TestToolbarActionViewController : public ToolbarActionViewController {
13 public:
14 explicit TestToolbarActionViewController(const std::string& id);
15 ~TestToolbarActionViewController() override;
16
17 // ToolbarActionViewController:
18 const std::string& GetId() const override;
19 void SetDelegate(ToolbarActionViewDelegate* delegate) override;
20 gfx::Image GetIcon(content::WebContents* web_contents) override;
21 gfx::ImageSkia GetIconWithBadge() override;
22 base::string16 GetActionName() const override;
23 base::string16 GetAccessibleName(content::WebContents* web_contents)
24 const override;
25 base::string16 GetTooltip(content::WebContents* web_contents)
26 const override;
27 bool IsEnabled(content::WebContents* web_contents) const override;
28 bool WantsToRun(content::WebContents* web_contents) const override;
29 bool HasPopup(content::WebContents* web_contents) const override;
30 void HidePopup() override;
31 gfx::NativeView GetPopupNativeView() override;
32 ui::MenuModel* GetContextMenu() override;
33 bool IsMenuRunning() const override;
34 bool CanDrag() const override;
35 bool ExecuteAction(bool by_user) override;
36 void UpdateState() override;
37
38 // Instruct the controller to fake showing a popup.
39 void ShowPopup(bool by_user);
40
41 // Configure the test controller. These also call UpdateDelegate().
42 void SetAccessibleName(const base::string16& name);
43 void SetTooltip(const base::string16& tooltip);
44 void SetEnabled(bool is_enabled);
45 void SetWantsToRun(bool wants_to_run);
46
47 int execute_action_count() const { return execute_action_count_; }
48
49 private:
50 // Updates the delegate, if one exists.
51 void UpdateDelegate();
52
53 // The id of the controller.
54 std::string id_;
55
56 // The delegate of the controller, if one exists.
57 ToolbarActionViewDelegate* delegate_;
58
59 // The optional accessible name and tooltip; by default these are empty.
60 base::string16 accessible_name_;
61 base::string16 tooltip_;
62
63 // Whether or not the action is enabled. Defaults to true.
64 bool is_enabled_;
65
66 // Whether or not the action wants to run. Defaults to false.
67 bool wants_to_run_;
68
69 // The number of times the action would have been executed.
70 int execute_action_count_;
71
72 DISALLOW_COPY_AND_ASSIGN(TestToolbarActionViewController);
73 };
74
75 #endif // CHROME_BROWSER_UI_TOOLBAR_TEST_TOOLBAR_ACTION_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698