OLD | NEW |
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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h" | 24 #include "chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/test/base/browser_with_test_window_test.h" | 26 #include "chrome/test/base/browser_with_test_window_test.h" |
27 #include "chrome/test/base/menu_model_test.h" | 27 #include "chrome/test/base/menu_model_test.h" |
28 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
29 #include "components/sessions/core/persistent_tab_restore_service.h" | 29 #include "components/sessions/core/persistent_tab_restore_service.h" |
30 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 30 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
31 #include "components/sessions/core/session_types.h" | 31 #include "components/sessions/core/session_types.h" |
32 #include "components/sync_driver/glue/synced_session.h" | 32 #include "components/sync_driver/glue/synced_session.h" |
33 #include "components/sync_driver/local_device_info_provider_mock.h" | 33 #include "components/sync_driver/local_device_info_provider_mock.h" |
| 34 #include "components/sync_sessions/fake_sync_sessions_client.h" |
34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
37 #include "sync/api/fake_sync_change_processor.h" | 38 #include "sync/api/fake_sync_change_processor.h" |
38 #include "sync/api/sync_error_factory_mock.h" | 39 #include "sync/api/sync_error_factory_mock.h" |
39 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 RecentTabsSubMenuModelTest() | 119 RecentTabsSubMenuModelTest() |
119 : sync_service_(&testing_profile_), | 120 : sync_service_(&testing_profile_), |
120 local_device_(new sync_driver::LocalDeviceInfoProviderMock( | 121 local_device_(new sync_driver::LocalDeviceInfoProviderMock( |
121 "RecentTabsSubMenuModelTest", | 122 "RecentTabsSubMenuModelTest", |
122 "Test Machine", | 123 "Test Machine", |
123 "Chromium 10k", | 124 "Chromium 10k", |
124 "Chrome 10k", | 125 "Chrome 10k", |
125 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, | 126 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, |
126 "device_id")) { | 127 "device_id")) { |
127 manager_.reset(new browser_sync::SessionsSyncManager( | 128 manager_.reset(new browser_sync::SessionsSyncManager( |
128 &testing_profile_, local_device_.get(), | 129 &fake_sync_sessions_client_, &testing_profile_, local_device_.get(), |
129 scoped_ptr<browser_sync::LocalSessionEventRouter>(new DummyRouter()), | 130 scoped_ptr<browser_sync::LocalSessionEventRouter>(new DummyRouter()), |
130 scoped_ptr<browser_sync::SyncedWindowDelegatesGetter>( | 131 scoped_ptr<browser_sync::SyncedWindowDelegatesGetter>( |
131 new browser_sync::BrowserSyncedWindowDelegatesGetter()))); | 132 new browser_sync::BrowserSyncedWindowDelegatesGetter()))); |
132 manager_->MergeDataAndStartSyncing( | 133 manager_->MergeDataAndStartSyncing( |
133 syncer::SESSIONS, | 134 syncer::SESSIONS, |
134 syncer::SyncDataList(), | 135 syncer::SyncDataList(), |
135 scoped_ptr<syncer::SyncChangeProcessor>( | 136 scoped_ptr<syncer::SyncChangeProcessor>( |
136 new syncer::FakeSyncChangeProcessor), | 137 new syncer::FakeSyncChangeProcessor), |
137 scoped_ptr<syncer::SyncErrorFactory>( | 138 scoped_ptr<syncer::SyncErrorFactory>( |
138 new syncer::SyncErrorFactoryMock)); | 139 new syncer::SyncErrorFactoryMock)); |
(...skipping 16 matching lines...) Expand all Loading... |
155 } | 156 } |
156 | 157 |
157 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { | 158 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { |
158 helper->ExportToSessionsSyncManager(manager_.get()); | 159 helper->ExportToSessionsSyncManager(manager_.get()); |
159 } | 160 } |
160 | 161 |
161 private: | 162 private: |
162 TestingProfile testing_profile_; | 163 TestingProfile testing_profile_; |
163 testing::NiceMock<ProfileSyncServiceMock> sync_service_; | 164 testing::NiceMock<ProfileSyncServiceMock> sync_service_; |
164 | 165 |
| 166 sync_sessions::FakeSyncSessionsClient fake_sync_sessions_client_; |
165 scoped_ptr<browser_sync::SessionsSyncManager> manager_; | 167 scoped_ptr<browser_sync::SessionsSyncManager> manager_; |
166 scoped_ptr<sync_driver::LocalDeviceInfoProviderMock> local_device_; | 168 scoped_ptr<sync_driver::LocalDeviceInfoProviderMock> local_device_; |
167 }; | 169 }; |
168 | 170 |
169 // Test disabled "Recently closed" header with no foreign tabs. | 171 // Test disabled "Recently closed" header with no foreign tabs. |
170 TEST_F(RecentTabsSubMenuModelTest, NoTabs) { | 172 TEST_F(RecentTabsSubMenuModelTest, NoTabs) { |
171 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); | 173 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); |
172 | 174 |
173 // Expected menu: | 175 // Expected menu: |
174 // Menu index Menu items | 176 // Menu index Menu items |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // 2 Recently closed heaer (disabled) | 596 // 2 Recently closed heaer (disabled) |
595 // 3 <separator> | 597 // 3 <separator> |
596 // 4 No tabs from other Devices | 598 // 4 No tabs from other Devices |
597 | 599 |
598 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); | 600 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); |
599 EXPECT_EQ(5, model.GetItemCount()); | 601 EXPECT_EQ(5, model.GetItemCount()); |
600 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); | 602 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); |
601 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(3)); | 603 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(3)); |
602 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(4)); | 604 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(4)); |
603 } | 605 } |
OLD | NEW |