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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc

Issue 627043002: replace OVERRIDE and FINAL with override and final in chrome/browser/ui/[a-s]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TestShelfModelObserver() 91 TestShelfModelObserver()
92 : added_(0), 92 : added_(0),
93 removed_(0), 93 removed_(0),
94 changed_(0) { 94 changed_(0) {
95 } 95 }
96 96
97 virtual ~TestShelfModelObserver() { 97 virtual ~TestShelfModelObserver() {
98 } 98 }
99 99
100 // Overridden from ash::ShelfModelObserver: 100 // Overridden from ash::ShelfModelObserver:
101 virtual void ShelfItemAdded(int index) OVERRIDE { 101 virtual void ShelfItemAdded(int index) override {
102 ++added_; 102 ++added_;
103 last_index_ = index; 103 last_index_ = index;
104 } 104 }
105 105
106 virtual void ShelfItemRemoved(int index, ash::ShelfID id) OVERRIDE { 106 virtual void ShelfItemRemoved(int index, ash::ShelfID id) override {
107 ++removed_; 107 ++removed_;
108 last_index_ = index; 108 last_index_ = index;
109 } 109 }
110 110
111 virtual void ShelfItemChanged(int index, 111 virtual void ShelfItemChanged(int index,
112 const ash::ShelfItem& old_item) OVERRIDE { 112 const ash::ShelfItem& old_item) override {
113 ++changed_; 113 ++changed_;
114 last_index_ = index; 114 last_index_ = index;
115 } 115 }
116 116
117 virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE { 117 virtual void ShelfItemMoved(int start_index, int target_index) override {
118 last_index_ = target_index; 118 last_index_ = target_index;
119 } 119 }
120 120
121 virtual void ShelfStatusChanged() OVERRIDE { 121 virtual void ShelfStatusChanged() override {
122 } 122 }
123 123
124 void clear_counts() { 124 void clear_counts() {
125 added_ = 0; 125 added_ = 0;
126 removed_ = 0; 126 removed_ = 0;
127 changed_ = 0; 127 changed_ = 0;
128 last_index_ = 0; 128 last_index_ = 0;
129 } 129 }
130 130
131 int added() const { return added_; } 131 int added() const { return added_; }
(...skipping 13 matching lines...) Expand all
145 // Test implementation of AppIconLoader. 145 // Test implementation of AppIconLoader.
146 class TestAppIconLoaderImpl : public extensions::AppIconLoader { 146 class TestAppIconLoaderImpl : public extensions::AppIconLoader {
147 public: 147 public:
148 TestAppIconLoaderImpl() : fetch_count_(0) { 148 TestAppIconLoaderImpl() : fetch_count_(0) {
149 } 149 }
150 150
151 virtual ~TestAppIconLoaderImpl() { 151 virtual ~TestAppIconLoaderImpl() {
152 } 152 }
153 153
154 // AppIconLoader implementation: 154 // AppIconLoader implementation:
155 virtual void FetchImage(const std::string& id) OVERRIDE { 155 virtual void FetchImage(const std::string& id) override {
156 ++fetch_count_; 156 ++fetch_count_;
157 } 157 }
158 158
159 virtual void ClearImage(const std::string& id) OVERRIDE { 159 virtual void ClearImage(const std::string& id) override {
160 } 160 }
161 161
162 virtual void UpdateImage(const std::string& id) OVERRIDE { 162 virtual void UpdateImage(const std::string& id) override {
163 } 163 }
164 164
165 int fetch_count() const { return fetch_count_; } 165 int fetch_count() const { return fetch_count_; }
166 166
167 private: 167 private:
168 int fetch_count_; 168 int fetch_count_;
169 169
170 DISALLOW_COPY_AND_ASSIGN(TestAppIconLoaderImpl); 170 DISALLOW_COPY_AND_ASSIGN(TestAppIconLoaderImpl);
171 }; 171 };
172 172
173 // Test implementation of AppTabHelper. 173 // Test implementation of AppTabHelper.
174 class TestAppTabHelperImpl : public ChromeLauncherController::AppTabHelper { 174 class TestAppTabHelperImpl : public ChromeLauncherController::AppTabHelper {
175 public: 175 public:
176 TestAppTabHelperImpl() {} 176 TestAppTabHelperImpl() {}
177 virtual ~TestAppTabHelperImpl() {} 177 virtual ~TestAppTabHelperImpl() {}
178 178
179 // Sets the id for the specified tab. The id is removed if Remove() is 179 // Sets the id for the specified tab. The id is removed if Remove() is
180 // invoked. 180 // invoked.
181 void SetAppID(content::WebContents* tab, const std::string& id) { 181 void SetAppID(content::WebContents* tab, const std::string& id) {
182 tab_id_map_[tab] = id; 182 tab_id_map_[tab] = id;
183 } 183 }
184 184
185 // Returns true if there is an id registered for |tab|. 185 // Returns true if there is an id registered for |tab|.
186 bool HasAppID(content::WebContents* tab) const { 186 bool HasAppID(content::WebContents* tab) const {
187 return tab_id_map_.find(tab) != tab_id_map_.end(); 187 return tab_id_map_.find(tab) != tab_id_map_.end();
188 } 188 }
189 189
190 // AppTabHelper implementation: 190 // AppTabHelper implementation:
191 virtual std::string GetAppID(content::WebContents* tab) OVERRIDE { 191 virtual std::string GetAppID(content::WebContents* tab) override {
192 return tab_id_map_.find(tab) != tab_id_map_.end() ? tab_id_map_[tab] : 192 return tab_id_map_.find(tab) != tab_id_map_.end() ? tab_id_map_[tab] :
193 std::string(); 193 std::string();
194 } 194 }
195 195
196 virtual bool IsValidIDForCurrentUser(const std::string& id) OVERRIDE { 196 virtual bool IsValidIDForCurrentUser(const std::string& id) override {
197 for (TabToStringMap::const_iterator i = tab_id_map_.begin(); 197 for (TabToStringMap::const_iterator i = tab_id_map_.begin();
198 i != tab_id_map_.end(); ++i) { 198 i != tab_id_map_.end(); ++i) {
199 if (i->second == id) 199 if (i->second == id)
200 return true; 200 return true;
201 } 201 }
202 return false; 202 return false;
203 } 203 }
204 204
205 virtual void SetCurrentUser(Profile* profile) OVERRIDE { 205 virtual void SetCurrentUser(Profile* profile) override {
206 // We can ignore this for now. 206 // We can ignore this for now.
207 } 207 }
208 208
209 private: 209 private:
210 typedef std::map<content::WebContents*, std::string> TabToStringMap; 210 typedef std::map<content::WebContents*, std::string> TabToStringMap;
211 211
212 TabToStringMap tab_id_map_; 212 TabToStringMap tab_id_map_;
213 213
214 DISALLOW_COPY_AND_ASSIGN(TestAppTabHelperImpl); 214 DISALLOW_COPY_AND_ASSIGN(TestAppTabHelperImpl);
215 }; 215 };
216 216
217 // Test implementation of a V2 app launcher item controller. 217 // Test implementation of a V2 app launcher item controller.
218 class TestV2AppLauncherItemController : public LauncherItemController { 218 class TestV2AppLauncherItemController : public LauncherItemController {
219 public: 219 public:
220 TestV2AppLauncherItemController(const std::string& app_id, 220 TestV2AppLauncherItemController(const std::string& app_id,
221 ChromeLauncherController* controller) 221 ChromeLauncherController* controller)
222 : LauncherItemController(LauncherItemController::TYPE_APP, 222 : LauncherItemController(LauncherItemController::TYPE_APP,
223 app_id, 223 app_id,
224 controller) { 224 controller) {
225 } 225 }
226 226
227 virtual ~TestV2AppLauncherItemController() {} 227 virtual ~TestV2AppLauncherItemController() {}
228 228
229 // Override for LauncherItemController: 229 // Override for LauncherItemController:
230 virtual bool IsOpen() const OVERRIDE { return true; } 230 virtual bool IsOpen() const override { return true; }
231 virtual bool IsVisible() const OVERRIDE { return true; } 231 virtual bool IsVisible() const override { return true; }
232 virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE {} 232 virtual void Launch(ash::LaunchSource source, int event_flags) override {}
233 virtual bool Activate(ash::LaunchSource source) OVERRIDE { return false; } 233 virtual bool Activate(ash::LaunchSource source) override { return false; }
234 virtual void Close() OVERRIDE {} 234 virtual void Close() override {}
235 virtual bool ItemSelected(const ui::Event& event) OVERRIDE { return false; } 235 virtual bool ItemSelected(const ui::Event& event) override { return false; }
236 virtual base::string16 GetTitle() OVERRIDE { return base::string16(); } 236 virtual base::string16 GetTitle() override { return base::string16(); }
237 virtual ChromeLauncherAppMenuItems GetApplicationList( 237 virtual ChromeLauncherAppMenuItems GetApplicationList(
238 int event_flags) OVERRIDE { 238 int event_flags) override {
239 ChromeLauncherAppMenuItems items; 239 ChromeLauncherAppMenuItems items;
240 items.push_back( 240 items.push_back(
241 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); 241 new ChromeLauncherAppMenuItem(base::string16(), NULL, false));
242 items.push_back( 242 items.push_back(
243 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); 243 new ChromeLauncherAppMenuItem(base::string16(), NULL, false));
244 return items.Pass(); 244 return items.Pass();
245 } 245 }
246 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) OVERRIDE { 246 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) override {
247 return NULL; 247 return NULL;
248 } 248 }
249 virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE { 249 virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override {
250 return NULL; 250 return NULL;
251 } 251 }
252 virtual bool IsDraggable() OVERRIDE { return false; } 252 virtual bool IsDraggable() override { return false; }
253 virtual bool ShouldShowTooltip() OVERRIDE { return false; } 253 virtual bool ShouldShowTooltip() override { return false; }
254 254
255 private: 255 private:
256 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); 256 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController);
257 }; 257 };
258 258
259 } // namespace 259 } // namespace
260 260
261 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { 261 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest {
262 protected: 262 protected:
263 ChromeLauncherControllerTest() 263 ChromeLauncherControllerTest()
264 : BrowserWithTestWindowTest( 264 : BrowserWithTestWindowTest(
265 Browser::TYPE_TABBED, 265 Browser::TYPE_TABBED,
266 chrome::HOST_DESKTOP_TYPE_ASH, 266 chrome::HOST_DESKTOP_TYPE_ASH,
267 false), 267 false),
268 test_controller_(NULL), 268 test_controller_(NULL),
269 extension_service_(NULL) { 269 extension_service_(NULL) {
270 } 270 }
271 271
272 virtual ~ChromeLauncherControllerTest() { 272 virtual ~ChromeLauncherControllerTest() {
273 } 273 }
274 274
275 virtual void SetUp() OVERRIDE { 275 virtual void SetUp() override {
276 BrowserWithTestWindowTest::SetUp(); 276 BrowserWithTestWindowTest::SetUp();
277 277
278 model_.reset(new ash::ShelfModel); 278 model_.reset(new ash::ShelfModel);
279 model_observer_.reset(new TestShelfModelObserver); 279 model_observer_.reset(new TestShelfModelObserver);
280 model_->AddObserver(model_observer_.get()); 280 model_->AddObserver(model_observer_.get());
281 281
282 if (ash::Shell::HasInstance()) { 282 if (ash::Shell::HasInstance()) {
283 item_delegate_manager_ = 283 item_delegate_manager_ =
284 ash::Shell::GetInstance()->shelf_item_delegate_manager(); 284 ash::Shell::GetInstance()->shelf_item_delegate_manager();
285 } else { 285 } else {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 InsertPrefValue(user_a, 2, extension3_->id()); 404 InsertPrefValue(user_a, 2, extension3_->id());
405 InsertPrefValue(user_a, 3, extension4_->id()); 405 InsertPrefValue(user_a, 3, extension4_->id());
406 InsertPrefValue(user_a, 4, extension5_->id()); 406 InsertPrefValue(user_a, 4, extension5_->id());
407 InsertPrefValue(user_a, 5, extension6_->id()); 407 InsertPrefValue(user_a, 5, extension6_->id());
408 408
409 // Set user b preferences. 409 // Set user b preferences.
410 InsertPrefValue(user_b, 0, extension7_->id()); 410 InsertPrefValue(user_b, 0, extension7_->id());
411 InsertPrefValue(user_b, 1, extension8_->id()); 411 InsertPrefValue(user_b, 1, extension8_->id());
412 } 412 }
413 413
414 virtual void TearDown() OVERRIDE { 414 virtual void TearDown() override {
415 if (!ash::Shell::HasInstance()) 415 if (!ash::Shell::HasInstance())
416 delete item_delegate_manager_; 416 delete item_delegate_manager_;
417 model_->RemoveObserver(model_observer_.get()); 417 model_->RemoveObserver(model_observer_.get());
418 model_observer_.reset(); 418 model_observer_.reset();
419 launcher_controller_.reset(); 419 launcher_controller_.reset();
420 model_.reset(); 420 model_.reset();
421 421
422 BrowserWithTestWindowTest::TearDown(); 422 BrowserWithTestWindowTest::TearDown();
423 } 423 }
424 424
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 // it. 623 // it.
624 class TestBrowserWindowAura : public TestBrowserWindow { 624 class TestBrowserWindowAura : public TestBrowserWindow {
625 public: 625 public:
626 // |native_window| will still be owned by the caller after the constructor 626 // |native_window| will still be owned by the caller after the constructor
627 // was called. 627 // was called.
628 explicit TestBrowserWindowAura(aura::Window* native_window) 628 explicit TestBrowserWindowAura(aura::Window* native_window)
629 : native_window_(native_window) { 629 : native_window_(native_window) {
630 } 630 }
631 virtual ~TestBrowserWindowAura() {} 631 virtual ~TestBrowserWindowAura() {}
632 632
633 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { 633 virtual gfx::NativeWindow GetNativeWindow() override {
634 return native_window_.get(); 634 return native_window_.get();
635 } 635 }
636 636
637 Browser* browser() { return browser_.get(); } 637 Browser* browser() { return browser_.get(); }
638 638
639 void CreateBrowser(const Browser::CreateParams& params) { 639 void CreateBrowser(const Browser::CreateParams& params) {
640 Browser::CreateParams create_params = params; 640 Browser::CreateParams create_params = params;
641 create_params.window = this; 641 create_params.window = this;
642 browser_.reset(new Browser(create_params)); 642 browser_.reset(new Browser(create_params));
643 } 643 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 } 676 }
677 virtual ~WebContentsDestroyedWatcher() {} 677 virtual ~WebContentsDestroyedWatcher() {}
678 678
679 // Waits until the WebContents is destroyed. 679 // Waits until the WebContents is destroyed.
680 void Wait() { 680 void Wait() {
681 message_loop_runner_->Run(); 681 message_loop_runner_->Run();
682 } 682 }
683 683
684 private: 684 private:
685 // Overridden WebContentsObserver methods. 685 // Overridden WebContentsObserver methods.
686 virtual void WebContentsDestroyed() OVERRIDE { 686 virtual void WebContentsDestroyed() override {
687 message_loop_runner_->Quit(); 687 message_loop_runner_->Quit();
688 } 688 }
689 689
690 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 690 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
691 691
692 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); 692 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher);
693 }; 693 };
694 694
695 // A V1 windowed application. 695 // A V1 windowed application.
696 class V1App : public TestBrowserWindow { 696 class V1App : public TestBrowserWindow {
(...skipping 20 matching lines...) Expand all
717 } 717 }
718 718
719 virtual ~V1App() { 719 virtual ~V1App() {
720 // close all tabs. Note that we do not need to destroy the browser itself. 720 // close all tabs. Note that we do not need to destroy the browser itself.
721 browser_->tab_strip_model()->CloseAllTabs(); 721 browser_->tab_strip_model()->CloseAllTabs();
722 } 722 }
723 723
724 Browser* browser() { return browser_.get(); } 724 Browser* browser() { return browser_.get(); }
725 725
726 // TestBrowserWindow override: 726 // TestBrowserWindow override:
727 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { 727 virtual gfx::NativeWindow GetNativeWindow() override {
728 return native_window_.get(); 728 return native_window_.get();
729 } 729 }
730 730
731 private: 731 private:
732 // The associated browser with this app. 732 // The associated browser with this app.
733 scoped_ptr<Browser> browser_; 733 scoped_ptr<Browser> browser_;
734 734
735 // The native window we use. 735 // The native window we use.
736 scoped_ptr<aura::Window> native_window_; 736 scoped_ptr<aura::Window> native_window_;
737 737
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest 774 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest
775 : public ChromeLauncherControllerTest { 775 : public ChromeLauncherControllerTest {
776 protected: 776 protected:
777 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { 777 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() {
778 } 778 }
779 779
780 virtual ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { 780 virtual ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() {
781 } 781 }
782 782
783 // Overwrite the Setup function to enable multi profile and needed objects. 783 // Overwrite the Setup function to enable multi profile and needed objects.
784 virtual void SetUp() OVERRIDE { 784 virtual void SetUp() override {
785 profile_manager_.reset( 785 profile_manager_.reset(
786 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 786 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
787 787
788 ASSERT_TRUE(profile_manager_->SetUp()); 788 ASSERT_TRUE(profile_manager_->SetUp());
789 789
790 // AvatarMenu and multiple profiles works after user logged in. 790 // AvatarMenu and multiple profiles works after user logged in.
791 profile_manager_->SetLoggedIn(true); 791 profile_manager_->SetLoggedIn(true);
792 792
793 // Initialize the UserManager singleton to a fresh FakeUserManager instance. 793 // Initialize the UserManager singleton to a fresh FakeUserManager instance.
794 user_manager_enabler_.reset( 794 user_manager_enabler_.reset(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 return v1_app; 896 return v1_app;
897 } 897 }
898 898
899 ash::test::TestSessionStateDelegate* session_delegate() { 899 ash::test::TestSessionStateDelegate* session_delegate() {
900 return static_cast<ash::test::TestSessionStateDelegate*>( 900 return static_cast<ash::test::TestSessionStateDelegate*>(
901 ash::Shell::GetInstance()->session_state_delegate()); 901 ash::Shell::GetInstance()->session_state_delegate());
902 } 902 }
903 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; } 903 ash::test::TestShellDelegate* shell_delegate() { return shell_delegate_; }
904 904
905 // Override BrowserWithTestWindowTest: 905 // Override BrowserWithTestWindowTest:
906 virtual TestingProfile* CreateProfile() OVERRIDE { 906 virtual TestingProfile* CreateProfile() override {
907 return CreateMultiUserProfile("user1"); 907 return CreateMultiUserProfile("user1");
908 } 908 }
909 virtual void DestroyProfile(TestingProfile* profile) OVERRIDE { 909 virtual void DestroyProfile(TestingProfile* profile) override {
910 // Delete the profile through our profile manager. 910 // Delete the profile through our profile manager.
911 ProfileToNameMap::iterator it = created_profiles_.find(profile); 911 ProfileToNameMap::iterator it = created_profiles_.find(profile);
912 DCHECK(it != created_profiles_.end()); 912 DCHECK(it != created_profiles_.end());
913 profile_manager_->DeleteTestingProfile(it->second); 913 profile_manager_->DeleteTestingProfile(it->second);
914 created_profiles_.erase(it); 914 created_profiles_.erase(it);
915 } 915 }
916 916
917 private: 917 private:
918 typedef std::map<Profile*, std::string> ProfileToNameMap; 918 typedef std::map<Profile*, std::string> ProfileToNameMap;
919 TestingProfileManager* profile_manager() { return profile_manager_.get(); } 919 TestingProfileManager* profile_manager() { return profile_manager_.get(); }
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 2686
2687 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2687 EXPECT_EQ(1, app_icon_loader->fetch_count());
2688 ASSERT_EQ(initial_size + 1, model_->items().size()); 2688 ASSERT_EQ(initial_size + 1, model_->items().size());
2689 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2689 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2690 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2690 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2691 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2691 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2692 2692
2693 launcher_controller_->UnpinAppWithID("1"); 2693 launcher_controller_->UnpinAppWithID("1");
2694 ASSERT_EQ(initial_size, model_->items().size()); 2694 ASSERT_EQ(initial_size, model_->items().size());
2695 } 2695 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698