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

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

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