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

Side by Side Diff: chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc

Issue 629603002: replace OVERRIDE and FINAL with override and final in chrome/browser/[r-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master 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 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/sync/sessions/sessions_sync_manager.h" 5 #include "chrome/browser/sync/sessions/sessions_sync_manager.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/sessions/session_tab_helper.h" 9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/sessions/session_types.h" 10 #include "chrome/browser/sessions/session_types.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 namespace { 46 namespace {
47 47
48 class SyncedWindowDelegateOverride : public SyncedWindowDelegate { 48 class SyncedWindowDelegateOverride : public SyncedWindowDelegate {
49 public: 49 public:
50 explicit SyncedWindowDelegateOverride(SyncedWindowDelegate* wrapped) 50 explicit SyncedWindowDelegateOverride(SyncedWindowDelegate* wrapped)
51 : wrapped_(wrapped) { 51 : wrapped_(wrapped) {
52 } 52 }
53 virtual ~SyncedWindowDelegateOverride() {} 53 virtual ~SyncedWindowDelegateOverride() {}
54 54
55 virtual bool HasWindow() const OVERRIDE { 55 virtual bool HasWindow() const override {
56 return wrapped_->HasWindow(); 56 return wrapped_->HasWindow();
57 } 57 }
58 58
59 virtual SessionID::id_type GetSessionId() const OVERRIDE { 59 virtual SessionID::id_type GetSessionId() const override {
60 return wrapped_->GetSessionId(); 60 return wrapped_->GetSessionId();
61 } 61 }
62 62
63 virtual int GetTabCount() const OVERRIDE { 63 virtual int GetTabCount() const override {
64 return wrapped_->GetTabCount(); 64 return wrapped_->GetTabCount();
65 } 65 }
66 66
67 virtual int GetActiveIndex() const OVERRIDE { 67 virtual int GetActiveIndex() const override {
68 return wrapped_->GetActiveIndex(); 68 return wrapped_->GetActiveIndex();
69 } 69 }
70 70
71 virtual bool IsApp() const OVERRIDE { 71 virtual bool IsApp() const override {
72 return wrapped_->IsApp(); 72 return wrapped_->IsApp();
73 } 73 }
74 74
75 virtual bool IsTypeTabbed() const OVERRIDE { 75 virtual bool IsTypeTabbed() const override {
76 return wrapped_->IsTypeTabbed(); 76 return wrapped_->IsTypeTabbed();
77 } 77 }
78 78
79 virtual bool IsTypePopup() const OVERRIDE { 79 virtual bool IsTypePopup() const override {
80 return wrapped_->IsTypePopup(); 80 return wrapped_->IsTypePopup();
81 } 81 }
82 82
83 virtual bool IsTabPinned(const SyncedTabDelegate* tab) const OVERRIDE { 83 virtual bool IsTabPinned(const SyncedTabDelegate* tab) const override {
84 return wrapped_->IsTabPinned(tab); 84 return wrapped_->IsTabPinned(tab);
85 } 85 }
86 86
87 virtual SyncedTabDelegate* GetTabAt(int index) const OVERRIDE { 87 virtual SyncedTabDelegate* GetTabAt(int index) const override {
88 if (tab_overrides_.find(index) != tab_overrides_.end()) 88 if (tab_overrides_.find(index) != tab_overrides_.end())
89 return tab_overrides_.find(index)->second; 89 return tab_overrides_.find(index)->second;
90 90
91 return wrapped_->GetTabAt(index); 91 return wrapped_->GetTabAt(index);
92 } 92 }
93 93
94 void OverrideTabAt(int index, 94 void OverrideTabAt(int index,
95 SyncedTabDelegate* delegate, 95 SyncedTabDelegate* delegate,
96 SessionID::id_type tab_id) { 96 SessionID::id_type tab_id) {
97 tab_overrides_[index] = delegate; 97 tab_overrides_[index] = delegate;
98 tab_id_overrides_[index] = tab_id; 98 tab_id_overrides_[index] = tab_id;
99 } 99 }
100 100
101 virtual SessionID::id_type GetTabIdAt(int index) const OVERRIDE { 101 virtual SessionID::id_type GetTabIdAt(int index) const override {
102 if (tab_id_overrides_.find(index) != tab_id_overrides_.end()) 102 if (tab_id_overrides_.find(index) != tab_id_overrides_.end())
103 return tab_id_overrides_.find(index)->second; 103 return tab_id_overrides_.find(index)->second;
104 return wrapped_->GetTabIdAt(index); 104 return wrapped_->GetTabIdAt(index);
105 } 105 }
106 106
107 virtual bool IsSessionRestoreInProgress() const OVERRIDE { 107 virtual bool IsSessionRestoreInProgress() const override {
108 return wrapped_->IsSessionRestoreInProgress(); 108 return wrapped_->IsSessionRestoreInProgress();
109 } 109 }
110 110
111 private: 111 private:
112 std::map<int, SyncedTabDelegate*> tab_overrides_; 112 std::map<int, SyncedTabDelegate*> tab_overrides_;
113 std::map<int, SessionID::id_type> tab_id_overrides_; 113 std::map<int, SessionID::id_type> tab_id_overrides_;
114 SyncedWindowDelegate* wrapped_; 114 SyncedWindowDelegate* wrapped_;
115 }; 115 };
116 116
117 class TestSyncedWindowDelegatesGetter : public SyncedWindowDelegatesGetter { 117 class TestSyncedWindowDelegatesGetter : public SyncedWindowDelegatesGetter {
118 public: 118 public:
119 TestSyncedWindowDelegatesGetter( 119 TestSyncedWindowDelegatesGetter(
120 const std::set<SyncedWindowDelegate*>& delegates) 120 const std::set<SyncedWindowDelegate*>& delegates)
121 : delegates_(delegates) {} 121 : delegates_(delegates) {}
122 122
123 virtual const std::set<SyncedWindowDelegate*> GetSyncedWindowDelegates() 123 virtual const std::set<SyncedWindowDelegate*> GetSyncedWindowDelegates()
124 OVERRIDE { 124 override {
125 return delegates_; 125 return delegates_;
126 } 126 }
127 private: 127 private:
128 const std::set<SyncedWindowDelegate*> delegates_; 128 const std::set<SyncedWindowDelegate*> delegates_;
129 }; 129 };
130 130
131 class TestSyncProcessorStub : public syncer::SyncChangeProcessor { 131 class TestSyncProcessorStub : public syncer::SyncChangeProcessor {
132 public: 132 public:
133 explicit TestSyncProcessorStub(syncer::SyncChangeList* output) 133 explicit TestSyncProcessorStub(syncer::SyncChangeList* output)
134 : output_(output) {} 134 : output_(output) {}
135 virtual syncer::SyncError ProcessSyncChanges( 135 virtual syncer::SyncError ProcessSyncChanges(
136 const tracked_objects::Location& from_here, 136 const tracked_objects::Location& from_here,
137 const syncer::SyncChangeList& change_list) OVERRIDE { 137 const syncer::SyncChangeList& change_list) override {
138 if (error_.IsSet()) { 138 if (error_.IsSet()) {
139 syncer::SyncError error = error_; 139 syncer::SyncError error = error_;
140 error_ = syncer::SyncError(); 140 error_ = syncer::SyncError();
141 return error; 141 return error;
142 } 142 }
143 143
144 if (output_) 144 if (output_)
145 output_->insert(output_->end(), change_list.begin(), change_list.end()); 145 output_->insert(output_->end(), change_list.begin(), change_list.end());
146 146
147 return syncer::SyncError(); 147 return syncer::SyncError();
148 } 148 }
149 149
150 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) 150 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type)
151 const OVERRIDE { 151 const override {
152 return sync_data_to_return_; 152 return sync_data_to_return_;
153 } 153 }
154 154
155 void FailProcessSyncChangesWith(const syncer::SyncError& error) { 155 void FailProcessSyncChangesWith(const syncer::SyncError& error) {
156 error_ = error; 156 error_ = error;
157 } 157 }
158 158
159 void SetSyncDataToReturn(const syncer::SyncDataList& data) { 159 void SetSyncDataToReturn(const syncer::SyncDataList& data) {
160 sync_data_to_return_ = data; 160 sync_data_to_return_ = data;
161 } 161 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 entity, 214 entity,
215 base::Time(), 215 base::Time(),
216 syncer::AttachmentIdList(), 216 syncer::AttachmentIdList(),
217 syncer::AttachmentServiceProxyForTest::Create())); 217 syncer::AttachmentServiceProxyForTest::Create()));
218 } 218 }
219 } 219 }
220 220
221 class DummyRouter : public LocalSessionEventRouter { 221 class DummyRouter : public LocalSessionEventRouter {
222 public: 222 public:
223 virtual ~DummyRouter() {} 223 virtual ~DummyRouter() {}
224 virtual void StartRoutingTo(LocalSessionEventHandler* handler) OVERRIDE {} 224 virtual void StartRoutingTo(LocalSessionEventHandler* handler) override {}
225 virtual void Stop() OVERRIDE {} 225 virtual void Stop() override {}
226 }; 226 };
227 227
228 scoped_ptr<LocalSessionEventRouter> NewDummyRouter() { 228 scoped_ptr<LocalSessionEventRouter> NewDummyRouter() {
229 return scoped_ptr<LocalSessionEventRouter>(new DummyRouter()); 229 return scoped_ptr<LocalSessionEventRouter>(new DummyRouter());
230 } 230 }
231 231
232 } // namespace 232 } // namespace
233 233
234 class SessionsSyncManagerTest 234 class SessionsSyncManagerTest
235 : public BrowserWithTestWindowTest { 235 : public BrowserWithTestWindowTest {
236 public: 236 public:
237 SessionsSyncManagerTest() 237 SessionsSyncManagerTest()
238 : test_processor_(NULL) { 238 : test_processor_(NULL) {
239 local_device_.reset(new LocalDeviceInfoProviderMock( 239 local_device_.reset(new LocalDeviceInfoProviderMock(
240 "cache_guid", 240 "cache_guid",
241 "Wayne Gretzky's Hacking Box", 241 "Wayne Gretzky's Hacking Box",
242 "Chromium 10k", 242 "Chromium 10k",
243 "Chrome 10k", 243 "Chrome 10k",
244 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, 244 sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
245 "device_id")); 245 "device_id"));
246 } 246 }
247 247
248 virtual void SetUp() OVERRIDE { 248 virtual void SetUp() override {
249 BrowserWithTestWindowTest::SetUp(); 249 BrowserWithTestWindowTest::SetUp();
250 browser_sync::NotificationServiceSessionsRouter* router( 250 browser_sync::NotificationServiceSessionsRouter* router(
251 new browser_sync::NotificationServiceSessionsRouter( 251 new browser_sync::NotificationServiceSessionsRouter(
252 profile(), syncer::SyncableService::StartSyncFlare())); 252 profile(), syncer::SyncableService::StartSyncFlare()));
253 manager_.reset(new SessionsSyncManager(profile(), local_device_.get(), 253 manager_.reset(new SessionsSyncManager(profile(), local_device_.get(),
254 scoped_ptr<LocalSessionEventRouter>(router))); 254 scoped_ptr<LocalSessionEventRouter>(router)));
255 } 255 }
256 256
257 virtual void TearDown() OVERRIDE { 257 virtual void TearDown() override {
258 test_processor_ = NULL; 258 test_processor_ = NULL;
259 helper()->Reset(); 259 helper()->Reset();
260 manager_.reset(); 260 manager_.reset();
261 BrowserWithTestWindowTest::TearDown(); 261 BrowserWithTestWindowTest::TearDown();
262 } 262 }
263 263
264 const DeviceInfo* GetLocalDeviceInfo() { 264 const DeviceInfo* GetLocalDeviceInfo() {
265 return local_device_->GetLocalDeviceInfo(); 265 return local_device_->GetLocalDeviceInfo();
266 } 266 }
267 267
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 class SyncedTabDelegateFake : public SyncedTabDelegate { 360 class SyncedTabDelegateFake : public SyncedTabDelegate {
361 public: 361 public:
362 SyncedTabDelegateFake() : current_entry_index_(0), 362 SyncedTabDelegateFake() : current_entry_index_(0),
363 pending_entry_index_(-1), 363 pending_entry_index_(-1),
364 is_supervised_(false), 364 is_supervised_(false),
365 sync_id_(-1), 365 sync_id_(-1),
366 blocked_navigations_(NULL) {} 366 blocked_navigations_(NULL) {}
367 virtual ~SyncedTabDelegateFake() {} 367 virtual ~SyncedTabDelegateFake() {}
368 368
369 virtual int GetCurrentEntryIndex() const OVERRIDE { 369 virtual int GetCurrentEntryIndex() const override {
370 return current_entry_index_; 370 return current_entry_index_;
371 } 371 }
372 void set_current_entry_index(int i) { 372 void set_current_entry_index(int i) {
373 current_entry_index_ = i; 373 current_entry_index_ = i;
374 } 374 }
375 375
376 virtual content::NavigationEntry* GetEntryAtIndex(int i) const OVERRIDE { 376 virtual content::NavigationEntry* GetEntryAtIndex(int i) const override {
377 const int size = entries_.size(); 377 const int size = entries_.size();
378 return (size < i + 1) ? NULL : entries_[i]; 378 return (size < i + 1) ? NULL : entries_[i];
379 } 379 }
380 380
381 void AppendEntry(content::NavigationEntry* entry) { 381 void AppendEntry(content::NavigationEntry* entry) {
382 entries_.push_back(entry); 382 entries_.push_back(entry);
383 } 383 }
384 384
385 virtual int GetEntryCount() const OVERRIDE { 385 virtual int GetEntryCount() const override {
386 return entries_.size(); 386 return entries_.size();
387 } 387 }
388 388
389 virtual int GetPendingEntryIndex() const OVERRIDE { 389 virtual int GetPendingEntryIndex() const override {
390 return pending_entry_index_; 390 return pending_entry_index_;
391 } 391 }
392 void set_pending_entry_index(int i) { 392 void set_pending_entry_index(int i) {
393 pending_entry_index_ = i; 393 pending_entry_index_ = i;
394 } 394 }
395 395
396 virtual SessionID::id_type GetWindowId() const OVERRIDE { 396 virtual SessionID::id_type GetWindowId() const override {
397 return SessionID::id_type(); 397 return SessionID::id_type();
398 } 398 }
399 399
400 virtual SessionID::id_type GetSessionId() const OVERRIDE { 400 virtual SessionID::id_type GetSessionId() const override {
401 return SessionID::id_type(); 401 return SessionID::id_type();
402 } 402 }
403 403
404 virtual bool IsBeingDestroyed() const OVERRIDE { return false; } 404 virtual bool IsBeingDestroyed() const override { return false; }
405 virtual Profile* profile() const OVERRIDE { return NULL; } 405 virtual Profile* profile() const override { return NULL; }
406 virtual std::string GetExtensionAppId() const OVERRIDE { 406 virtual std::string GetExtensionAppId() const override {
407 return std::string(); 407 return std::string();
408 } 408 }
409 virtual content::NavigationEntry* GetPendingEntry() const OVERRIDE { 409 virtual content::NavigationEntry* GetPendingEntry() const override {
410 return NULL; 410 return NULL;
411 } 411 }
412 virtual content::NavigationEntry* GetActiveEntry() const OVERRIDE { 412 virtual content::NavigationEntry* GetActiveEntry() const override {
413 return NULL; 413 return NULL;
414 } 414 }
415 virtual bool ProfileIsSupervised() const OVERRIDE { 415 virtual bool ProfileIsSupervised() const override {
416 return is_supervised_; 416 return is_supervised_;
417 } 417 }
418 void set_is_supervised(bool is_supervised) { is_supervised_ = is_supervised; } 418 void set_is_supervised(bool is_supervised) { is_supervised_ = is_supervised; }
419 virtual const std::vector<const content::NavigationEntry*>* 419 virtual const std::vector<const content::NavigationEntry*>*
420 GetBlockedNavigations() const OVERRIDE { 420 GetBlockedNavigations() const override {
421 return blocked_navigations_; 421 return blocked_navigations_;
422 } 422 }
423 void set_blocked_navigations( 423 void set_blocked_navigations(
424 std::vector<const content::NavigationEntry*>* navs) { 424 std::vector<const content::NavigationEntry*>* navs) {
425 blocked_navigations_ = navs; 425 blocked_navigations_ = navs;
426 } 426 }
427 virtual bool IsPinned() const OVERRIDE { 427 virtual bool IsPinned() const override {
428 return false; 428 return false;
429 } 429 }
430 virtual bool HasWebContents() const OVERRIDE { 430 virtual bool HasWebContents() const override {
431 return false; 431 return false;
432 } 432 }
433 virtual content::WebContents* GetWebContents() const OVERRIDE { 433 virtual content::WebContents* GetWebContents() const override {
434 return NULL; 434 return NULL;
435 } 435 }
436 436
437 // Session sync related methods. 437 // Session sync related methods.
438 virtual int GetSyncId() const OVERRIDE { 438 virtual int GetSyncId() const override {
439 return sync_id_; 439 return sync_id_;
440 } 440 }
441 virtual void SetSyncId(int sync_id) OVERRIDE { 441 virtual void SetSyncId(int sync_id) override {
442 sync_id_ = sync_id; 442 sync_id_ = sync_id;
443 } 443 }
444 444
445 void reset() { 445 void reset() {
446 current_entry_index_ = 0; 446 current_entry_index_ = 0;
447 pending_entry_index_ = -1; 447 pending_entry_index_ = -1;
448 sync_id_ = -1; 448 sync_id_ = -1;
449 entries_.clear(); 449 entries_.clear();
450 } 450 }
451 451
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 public: 1833 public:
1834 SessionNotificationObserver() : notified_of_update_(false), 1834 SessionNotificationObserver() : notified_of_update_(false),
1835 notified_of_refresh_(false) { 1835 notified_of_refresh_(false) {
1836 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, 1836 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
1837 content::NotificationService::AllSources()); 1837 content::NotificationService::AllSources());
1838 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, 1838 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
1839 content::NotificationService::AllSources()); 1839 content::NotificationService::AllSources());
1840 } 1840 }
1841 virtual void Observe(int type, 1841 virtual void Observe(int type,
1842 const content::NotificationSource& source, 1842 const content::NotificationSource& source,
1843 const content::NotificationDetails& details) OVERRIDE { 1843 const content::NotificationDetails& details) override {
1844 switch (type) { 1844 switch (type) {
1845 case chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED: 1845 case chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED:
1846 notified_of_update_ = true; 1846 notified_of_update_ = true;
1847 break; 1847 break;
1848 case chrome::NOTIFICATION_SYNC_REFRESH_LOCAL: 1848 case chrome::NOTIFICATION_SYNC_REFRESH_LOCAL:
1849 notified_of_refresh_ = true; 1849 notified_of_refresh_ = true;
1850 break; 1850 break;
1851 default: 1851 default:
1852 NOTREACHED(); 1852 NOTREACHED();
1853 break; 1853 break;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 base::Time(), 2001 base::Time(),
2002 syncer::AttachmentIdList(), 2002 syncer::AttachmentIdList(),
2003 syncer::AttachmentServiceProxyForTest::Create())); 2003 syncer::AttachmentServiceProxyForTest::Create()));
2004 } 2004 }
2005 2005
2006 syncer::SyncChangeList output; 2006 syncer::SyncChangeList output;
2007 InitWithSyncDataTakeOutput(initial_data, &output); 2007 InitWithSyncDataTakeOutput(initial_data, &output);
2008 } 2008 }
2009 2009
2010 } // namespace browser_sync 2010 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/sessions_sync_manager.h ('k') | chrome/browser/sync/startup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698