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

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

Issue 2343463003: [Sync] Fix namespaces for the sync_sessions component. (Closed)
Patch Set: Fix gn. Created 4 years, 3 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 namespace { 47 namespace {
48 48
49 // This copies parts of MenuModelTest::Delegate and combines them with the 49 // This copies parts of MenuModelTest::Delegate and combines them with the
50 // RecentTabsSubMenuModel since RecentTabsSubMenuModel is a 50 // RecentTabsSubMenuModel since RecentTabsSubMenuModel is a
51 // SimpleMenuModel::Delegate and not just derived from SimpleMenuModel. 51 // SimpleMenuModel::Delegate and not just derived from SimpleMenuModel.
52 class TestRecentTabsSubMenuModel : public RecentTabsSubMenuModel { 52 class TestRecentTabsSubMenuModel : public RecentTabsSubMenuModel {
53 public: 53 public:
54 TestRecentTabsSubMenuModel(ui::AcceleratorProvider* provider, 54 TestRecentTabsSubMenuModel(ui::AcceleratorProvider* provider,
55 Browser* browser, 55 Browser* browser,
56 sync_driver::OpenTabsUIDelegate* delegate) 56 sync_sessions::OpenTabsUIDelegate* delegate)
57 : RecentTabsSubMenuModel(provider, browser, delegate), 57 : RecentTabsSubMenuModel(provider, browser, delegate),
58 execute_count_(0), 58 execute_count_(0),
59 enable_count_(0) {} 59 enable_count_(0) {}
60 60
61 // Testing overrides to ui::SimpleMenuModel::Delegate: 61 // Testing overrides to ui::SimpleMenuModel::Delegate:
62 bool IsCommandIdEnabled(int command_id) const override { 62 bool IsCommandIdEnabled(int command_id) const override {
63 bool val = RecentTabsSubMenuModel::IsCommandIdEnabled(command_id); 63 bool val = RecentTabsSubMenuModel::IsCommandIdEnabled(command_id);
64 if (val) 64 if (val)
65 ++enable_count_; 65 ++enable_count_;
66 return val; 66 return val;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 bool got_changes() const { return got_changes_; } 101 bool got_changes() const { return got_changes_; }
102 102
103 private: 103 private:
104 ui::MenuModel* model_; 104 ui::MenuModel* model_;
105 bool got_changes_; 105 bool got_changes_;
106 106
107 DISALLOW_COPY_AND_ASSIGN(TestRecentTabsMenuModelDelegate); 107 DISALLOW_COPY_AND_ASSIGN(TestRecentTabsMenuModelDelegate);
108 }; 108 };
109 109
110 class DummyRouter : public browser_sync::LocalSessionEventRouter { 110 class DummyRouter : public sync_sessions::LocalSessionEventRouter {
111 public: 111 public:
112 ~DummyRouter() override {} 112 ~DummyRouter() override {}
113 void StartRoutingTo( 113 void StartRoutingTo(
114 browser_sync::LocalSessionEventHandler* handler) override {} 114 sync_sessions::LocalSessionEventHandler* handler) override {}
115 void Stop() override {} 115 void Stop() override {}
116 }; 116 };
117 117
118 } // namespace 118 } // namespace
119 119
120 class RecentTabsSubMenuModelTest 120 class RecentTabsSubMenuModelTest
121 : public BrowserWithTestWindowTest { 121 : public BrowserWithTestWindowTest {
122 public: 122 public:
123 RecentTabsSubMenuModelTest() 123 RecentTabsSubMenuModelTest()
124 : sync_service_(CreateProfileSyncServiceParamsForTest(&testing_profile_)), 124 : sync_service_(CreateProfileSyncServiceParamsForTest(&testing_profile_)),
125 local_device_(new sync_driver::LocalDeviceInfoProviderMock( 125 local_device_(new sync_driver::LocalDeviceInfoProviderMock(
126 "RecentTabsSubMenuModelTest", 126 "RecentTabsSubMenuModelTest",
127 "Test Machine", 127 "Test Machine",
128 "Chromium 10k", 128 "Chromium 10k",
129 "Chrome 10k", 129 "Chrome 10k",
130 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, 130 sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
131 "device_id")) { 131 "device_id")) {
132 sync_prefs_.reset(new sync_driver::SyncPrefs(testing_profile_.GetPrefs())); 132 sync_prefs_.reset(new sync_driver::SyncPrefs(testing_profile_.GetPrefs()));
133 manager_.reset(new browser_sync::SessionsSyncManager( 133 manager_.reset(new sync_sessions::SessionsSyncManager(
134 sync_service_.GetSyncClient()->GetSyncSessionsClient(), 134 sync_service_.GetSyncClient()->GetSyncSessionsClient(),
135 sync_prefs_.get(), local_device_.get(), 135 sync_prefs_.get(), local_device_.get(),
136 std::unique_ptr<browser_sync::LocalSessionEventRouter>( 136 std::unique_ptr<sync_sessions::LocalSessionEventRouter>(
137 new DummyRouter()), 137 new DummyRouter()),
138 base::Closure(), base::Closure())); 138 base::Closure(), base::Closure()));
139 manager_->MergeDataAndStartSyncing( 139 manager_->MergeDataAndStartSyncing(
140 syncer::SESSIONS, syncer::SyncDataList(), 140 syncer::SESSIONS, syncer::SyncDataList(),
141 std::unique_ptr<syncer::SyncChangeProcessor>( 141 std::unique_ptr<syncer::SyncChangeProcessor>(
142 new syncer::FakeSyncChangeProcessor), 142 new syncer::FakeSyncChangeProcessor),
143 std::unique_ptr<syncer::SyncErrorFactory>( 143 std::unique_ptr<syncer::SyncErrorFactory>(
144 new syncer::SyncErrorFactoryMock)); 144 new syncer::SyncErrorFactoryMock));
145 } 145 }
146 146
147 void WaitForLoadFromLastSession() { 147 void WaitForLoadFromLastSession() {
148 content::RunAllBlockingPoolTasksUntilIdle(); 148 content::RunAllBlockingPoolTasksUntilIdle();
149 } 149 }
150 150
151 static std::unique_ptr<KeyedService> GetTabRestoreService( 151 static std::unique_ptr<KeyedService> GetTabRestoreService(
152 content::BrowserContext* browser_context) { 152 content::BrowserContext* browser_context) {
153 return base::MakeUnique<sessions::PersistentTabRestoreService>( 153 return base::MakeUnique<sessions::PersistentTabRestoreService>(
154 base::WrapUnique(new ChromeTabRestoreServiceClient( 154 base::WrapUnique(new ChromeTabRestoreServiceClient(
155 Profile::FromBrowserContext(browser_context))), 155 Profile::FromBrowserContext(browser_context))),
156 nullptr); 156 nullptr);
157 } 157 }
158 158
159 sync_driver::OpenTabsUIDelegate* GetOpenTabsDelegate() { 159 sync_sessions::OpenTabsUIDelegate* GetOpenTabsDelegate() {
160 return manager_.get(); 160 return manager_.get();
161 } 161 }
162 162
163 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { 163 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) {
164 helper->ExportToSessionsSyncManager(manager_.get()); 164 helper->ExportToSessionsSyncManager(manager_.get());
165 } 165 }
166 166
167 private: 167 private:
168 TestingProfile testing_profile_; 168 TestingProfile testing_profile_;
169 ProfileSyncServiceMock sync_service_; 169 ProfileSyncServiceMock sync_service_;
170 std::unique_ptr<sync_driver::SyncPrefs> sync_prefs_; 170 std::unique_ptr<sync_driver::SyncPrefs> sync_prefs_;
171 std::unique_ptr<browser_sync::SessionsSyncManager> manager_; 171 std::unique_ptr<sync_sessions::SessionsSyncManager> manager_;
172 std::unique_ptr<sync_driver::LocalDeviceInfoProviderMock> local_device_; 172 std::unique_ptr<sync_driver::LocalDeviceInfoProviderMock> local_device_;
173 }; 173 };
174 174
175 // Test disabled "Recently closed" header with no foreign tabs. 175 // Test disabled "Recently closed" header with no foreign tabs.
176 TEST_F(RecentTabsSubMenuModelTest, NoTabs) { 176 TEST_F(RecentTabsSubMenuModelTest, NoTabs) {
177 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); 177 TestRecentTabsSubMenuModel model(NULL, browser(), NULL);
178 178
179 // Expected menu: 179 // Expected menu:
180 // Menu index Menu items 180 // Menu index Menu items
181 // --------------------------------------------- 181 // ---------------------------------------------
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // 2 Recently closed heaer (disabled) 607 // 2 Recently closed heaer (disabled)
608 // 3 <separator> 608 // 3 <separator>
609 // 4 No tabs from other Devices 609 // 4 No tabs from other Devices
610 610
611 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); 611 TestRecentTabsSubMenuModel model(NULL, browser(), NULL);
612 EXPECT_EQ(5, model.GetItemCount()); 612 EXPECT_EQ(5, model.GetItemCount());
613 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); 613 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2));
614 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(3)); 614 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(3));
615 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(4)); 615 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(4));
616 } 616 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc ('k') | chrome/browser/ui/webui/favicon_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698