OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" | 5 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 10 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 bool enabled; | 35 bool enabled; |
36 bool checked; | 36 bool checked; |
37 bool hidden; | 37 bool hidden; |
38 base::string16 title; | 38 base::string16 title; |
39 }; | 39 }; |
40 | 40 |
41 MockRenderViewContextMenu() : observer_(NULL), profile_(new TestingProfile) {} | 41 MockRenderViewContextMenu() : observer_(NULL), profile_(new TestingProfile) {} |
42 virtual ~MockRenderViewContextMenu() {} | 42 virtual ~MockRenderViewContextMenu() {} |
43 | 43 |
44 // SimpleMenuModel::Delegate implementation. | 44 // SimpleMenuModel::Delegate implementation. |
45 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { | 45 virtual bool IsCommandIdChecked(int command_id) const override { |
46 return observer_->IsCommandIdChecked(command_id); | 46 return observer_->IsCommandIdChecked(command_id); |
47 } | 47 } |
48 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 48 virtual bool IsCommandIdEnabled(int command_id) const override { |
49 return observer_->IsCommandIdEnabled(command_id); | 49 return observer_->IsCommandIdEnabled(command_id); |
50 } | 50 } |
51 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 51 virtual void ExecuteCommand(int command_id, int event_flags) override { |
52 observer_->ExecuteCommand(command_id); | 52 observer_->ExecuteCommand(command_id); |
53 } | 53 } |
54 virtual void MenuWillShow(ui::SimpleMenuModel* source) OVERRIDE {} | 54 virtual void MenuWillShow(ui::SimpleMenuModel* source) override {} |
55 virtual void MenuClosed(ui::SimpleMenuModel* source) OVERRIDE {} | 55 virtual void MenuClosed(ui::SimpleMenuModel* source) override {} |
56 virtual bool GetAcceleratorForCommandId( | 56 virtual bool GetAcceleratorForCommandId( |
57 int command_id, | 57 int command_id, |
58 ui::Accelerator* accelerator) OVERRIDE { | 58 ui::Accelerator* accelerator) override { |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 // RenderViewContextMenuProxy implementation. | 62 // RenderViewContextMenuProxy implementation. |
63 virtual void AddMenuItem(int command_id, | 63 virtual void AddMenuItem(int command_id, |
64 const base::string16& title) OVERRIDE {} | 64 const base::string16& title) override {} |
65 virtual void AddCheckItem(int command_id, | 65 virtual void AddCheckItem(int command_id, |
66 const base::string16& title) OVERRIDE {} | 66 const base::string16& title) override {} |
67 virtual void AddSeparator() OVERRIDE {} | 67 virtual void AddSeparator() override {} |
68 virtual void AddSubMenu(int command_id, | 68 virtual void AddSubMenu(int command_id, |
69 const base::string16& label, | 69 const base::string16& label, |
70 ui::MenuModel* model) OVERRIDE {} | 70 ui::MenuModel* model) override {} |
71 virtual void UpdateMenuItem(int command_id, | 71 virtual void UpdateMenuItem(int command_id, |
72 bool enabled, | 72 bool enabled, |
73 bool hidden, | 73 bool hidden, |
74 const base::string16& title) OVERRIDE {} | 74 const base::string16& title) override {} |
75 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE { | 75 virtual RenderViewHost* GetRenderViewHost() const override { |
76 return NULL; | 76 return NULL; |
77 } | 77 } |
78 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { | 78 virtual content::BrowserContext* GetBrowserContext() const override { |
79 return profile_.get(); | 79 return profile_.get(); |
80 } | 80 } |
81 virtual content::WebContents* GetWebContents() const OVERRIDE { | 81 virtual content::WebContents* GetWebContents() const override { |
82 return NULL; | 82 return NULL; |
83 } | 83 } |
84 | 84 |
85 // Attaches a RenderViewContextMenuObserver to be tested. | 85 // Attaches a RenderViewContextMenuObserver to be tested. |
86 void SetObserver(RenderViewContextMenuObserver* observer) { | 86 void SetObserver(RenderViewContextMenuObserver* observer) { |
87 observer_ = observer; | 87 observer_ = observer; |
88 } | 88 } |
89 | 89 |
90 // Returns the number of items added by the test. | 90 // Returns the number of items added by the test. |
91 size_t GetMenuSize() const { | 91 size_t GetMenuSize() const { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 EXPECT_TRUE(menu->IsCommandIdChecked(IDC_CHECK_SPELLING_WHILE_TYPING)); | 148 EXPECT_TRUE(menu->IsCommandIdChecked(IDC_CHECK_SPELLING_WHILE_TYPING)); |
149 | 149 |
150 // Select this item and verify that the "Check Spelling While Typing" item is | 150 // Select this item and verify that the "Check Spelling While Typing" item is |
151 // not checked. Also, verify that the value of "browser.enable_spellchecking" | 151 // not checked. Also, verify that the value of "browser.enable_spellchecking" |
152 // is now false. | 152 // is now false. |
153 menu->ExecuteCommand(IDC_CHECK_SPELLING_WHILE_TYPING, 0); | 153 menu->ExecuteCommand(IDC_CHECK_SPELLING_WHILE_TYPING, 0); |
154 EXPECT_FALSE( | 154 EXPECT_FALSE( |
155 menu->GetPrefs()->GetBoolean(prefs::kEnableContinuousSpellcheck)); | 155 menu->GetPrefs()->GetBoolean(prefs::kEnableContinuousSpellcheck)); |
156 EXPECT_FALSE(menu->IsCommandIdChecked(IDC_CHECK_SPELLING_WHILE_TYPING)); | 156 EXPECT_FALSE(menu->IsCommandIdChecked(IDC_CHECK_SPELLING_WHILE_TYPING)); |
157 } | 157 } |
OLD | NEW |