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

Side by Side Diff: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc

Issue 398423002: Sync: Refactoring of DEVICE_INFO syncable type - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed wrong signin_scoped_device_id assert from LocalDeviceInfoProvider. Created 6 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/toolbar/recent_tabs_sub_menu_model.h" 5 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/sessions/session_service.h" 10 #include "chrome/browser/sessions/session_service.h"
11 #include "chrome/browser/sessions/session_service_factory.h" 11 #include "chrome/browser/sessions/session_service_factory.h"
12 #include "chrome/browser/sessions/session_types.h" 12 #include "chrome/browser/sessions/session_types.h"
13 #include "chrome/browser/sessions/persistent_tab_restore_service.h" 13 #include "chrome/browser/sessions/persistent_tab_restore_service.h"
14 #include "chrome/browser/sessions/tab_restore_service_factory.h" 14 #include "chrome/browser/sessions/tab_restore_service_factory.h"
15 #include "chrome/browser/sync/glue/local_device_info_provider_mock.h"
15 #include "chrome/browser/sync/glue/synced_session.h" 16 #include "chrome/browser/sync/glue/synced_session.h"
16 #include "chrome/browser/sync/profile_sync_service_mock.h" 17 #include "chrome/browser/sync/profile_sync_service_mock.h"
17 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" 18 #include "chrome/browser/sync/sessions/sessions_sync_manager.h"
18 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_tabstrip.h" 20 #include "chrome/browser/ui/browser_tabstrip.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h" 22 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/test/base/browser_with_test_window_test.h" 24 #include "chrome/test/base/browser_with_test_window_test.h"
24 #include "chrome/test/base/menu_model_test.h" 25 #include "chrome/test/base/menu_model_test.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 public: 103 public:
103 virtual ~DummyRouter() {} 104 virtual ~DummyRouter() {}
104 virtual void StartRoutingTo( 105 virtual void StartRoutingTo(
105 browser_sync::LocalSessionEventHandler* handler) OVERRIDE {} 106 browser_sync::LocalSessionEventHandler* handler) OVERRIDE {}
106 virtual void Stop() OVERRIDE {} 107 virtual void Stop() OVERRIDE {}
107 }; 108 };
108 109
109 } // namespace 110 } // namespace
110 111
111 class RecentTabsSubMenuModelTest 112 class RecentTabsSubMenuModelTest
112 : public BrowserWithTestWindowTest, 113 : public BrowserWithTestWindowTest {
113 public browser_sync::SessionsSyncManager::SyncInternalApiDelegate {
114 public: 114 public:
115 RecentTabsSubMenuModelTest() 115 RecentTabsSubMenuModelTest()
116 : sync_service_(&testing_profile_) { 116 : sync_service_(&testing_profile_),
117 local_device_(new browser_sync::LocalDeviceInfoProviderMock(
118 "RecentTabsSubMenuModelTest",
119 "Test Machine",
120 "Chromium 10k",
121 "Chrome 10k",
122 sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
123 "device_id")) {
117 manager_.reset(new browser_sync::SessionsSyncManager( 124 manager_.reset(new browser_sync::SessionsSyncManager(
118 &testing_profile_, 125 &testing_profile_,
119 this, 126 local_device_.get(),
120 scoped_ptr<browser_sync::LocalSessionEventRouter>( 127 scoped_ptr<browser_sync::LocalSessionEventRouter>(
121 new DummyRouter()))); 128 new DummyRouter())));
122 manager_->MergeDataAndStartSyncing( 129 manager_->MergeDataAndStartSyncing(
123 syncer::SESSIONS, 130 syncer::SESSIONS,
124 syncer::SyncDataList(), 131 syncer::SyncDataList(),
125 scoped_ptr<syncer::SyncChangeProcessor>( 132 scoped_ptr<syncer::SyncChangeProcessor>(
126 new syncer::FakeSyncChangeProcessor), 133 new syncer::FakeSyncChangeProcessor),
127 scoped_ptr<syncer::SyncErrorFactory>( 134 scoped_ptr<syncer::SyncErrorFactory>(
128 new syncer::SyncErrorFactoryMock)); 135 new syncer::SyncErrorFactoryMock));
129 } 136 }
130 137
131 void WaitForLoadFromLastSession() { 138 void WaitForLoadFromLastSession() {
132 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 139 content::BrowserThread::GetBlockingPool()->FlushForTesting();
133 base::RunLoop().RunUntilIdle(); 140 base::RunLoop().RunUntilIdle();
134 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 141 content::BrowserThread::GetBlockingPool()->FlushForTesting();
135 } 142 }
136 143
137 static KeyedService* GetTabRestoreService( 144 static KeyedService* GetTabRestoreService(
138 content::BrowserContext* browser_context) { 145 content::BrowserContext* browser_context) {
139 // Ownership is tranfered to the profile. 146 // Ownership is tranfered to the profile.
140 return new PersistentTabRestoreService( 147 return new PersistentTabRestoreService(
141 Profile::FromBrowserContext(browser_context), NULL); 148 Profile::FromBrowserContext(browser_context), NULL);
142 } 149 }
143 150
144
145 browser_sync::OpenTabsUIDelegate* GetOpenTabsDelegate() { 151 browser_sync::OpenTabsUIDelegate* GetOpenTabsDelegate() {
146 return manager_.get(); 152 return manager_.get();
147 } 153 }
148 154
149 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { 155 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) {
150 helper->ExportToSessionsSyncManager(manager_.get()); 156 helper->ExportToSessionsSyncManager(manager_.get());
151 } 157 }
152 158
153 virtual scoped_ptr<browser_sync::DeviceInfo> GetLocalDeviceInfo()
154 const OVERRIDE {
155 return scoped_ptr<browser_sync::DeviceInfo>(
156 new browser_sync::DeviceInfo(GetLocalSyncCacheGUID(),
157 "Test Machine",
158 "Chromium 10k",
159 "Chrome 10k",
160 sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
161 "device_id"));
162 }
163
164 virtual std::string GetLocalSyncCacheGUID() const OVERRIDE {
165 return "RecentTabsSubMenuModelTest";
166 }
167
168 private: 159 private:
169 TestingProfile testing_profile_; 160 TestingProfile testing_profile_;
170 testing::NiceMock<ProfileSyncServiceMock> sync_service_; 161 testing::NiceMock<ProfileSyncServiceMock> sync_service_;
171 162
172 scoped_ptr<browser_sync::SessionsSyncManager> manager_; 163 scoped_ptr<browser_sync::SessionsSyncManager> manager_;
164 scoped_ptr<browser_sync::LocalDeviceInfoProviderMock> local_device_;
173 }; 165 };
174 166
175 // Test disabled "Recently closed" header with no foreign tabs. 167 // Test disabled "Recently closed" header with no foreign tabs.
176 TEST_F(RecentTabsSubMenuModelTest, NoTabs) { 168 TEST_F(RecentTabsSubMenuModelTest, NoTabs) {
177 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); 169 TestRecentTabsSubMenuModel model(NULL, browser(), NULL);
178 170
179 // Expected menu: 171 // Expected menu:
180 // Menu index Menu items 172 // Menu index Menu items
181 // --------------------------------------------- 173 // ---------------------------------------------
182 // 0 Recently closed header (disabled) 174 // 0 Recently closed header (disabled)
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // 0 Recently closed heaer (disabled) 552 // 0 Recently closed heaer (disabled)
561 // 1 <separator> 553 // 1 <separator>
562 // 2 No tabs from other Devices 554 // 2 No tabs from other Devices
563 555
564 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); 556 TestRecentTabsSubMenuModel model(NULL, browser(), NULL);
565 EXPECT_EQ(3, model.GetItemCount()); 557 EXPECT_EQ(3, model.GetItemCount());
566 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(0)); 558 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(0));
567 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(1)); 559 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(1));
568 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); 560 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2));
569 } 561 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698