OLD | NEW |
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/at_exit.h" |
7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/sessions/session_id.h" | 10 #include "chrome/browser/sessions/session_id.h" |
10 #include "chrome/browser/sessions/session_tab_helper.h" | 11 #include "chrome/browser/sessions/session_tab_helper.h" |
11 #include "chrome/browser/sessions/session_types.h" | 12 #include "chrome/browser/sessions/session_types.h" |
12 #include "chrome/browser/sync/glue/device_info.h" | 13 #include "chrome/browser/sync/glue/device_info.h" |
13 #include "chrome/browser/sync/glue/session_sync_test_helper.h" | 14 #include "chrome/browser/sync/glue/session_sync_test_helper.h" |
14 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | 15 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
15 #include "chrome/browser/sync/glue/synced_window_delegate.h" | 16 #include "chrome/browser/sync/glue/synced_window_delegate.h" |
16 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" | 17 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 228 |
228 } // namespace | 229 } // namespace |
229 | 230 |
230 class SessionsSyncManagerTest | 231 class SessionsSyncManagerTest |
231 : public BrowserWithTestWindowTest, | 232 : public BrowserWithTestWindowTest, |
232 public SessionsSyncManager::SyncInternalApiDelegate { | 233 public SessionsSyncManager::SyncInternalApiDelegate { |
233 public: | 234 public: |
234 SessionsSyncManagerTest() : test_processor_(NULL) {} | 235 SessionsSyncManagerTest() : test_processor_(NULL) {} |
235 | 236 |
236 virtual void SetUp() OVERRIDE { | 237 virtual void SetUp() OVERRIDE { |
| 238 at_exit_.reset(new base::ShadowingAtExitManager()); |
237 BrowserWithTestWindowTest::SetUp(); | 239 BrowserWithTestWindowTest::SetUp(); |
238 browser_sync::NotificationServiceSessionsRouter* router( | 240 browser_sync::NotificationServiceSessionsRouter* router( |
239 new browser_sync::NotificationServiceSessionsRouter( | 241 new browser_sync::NotificationServiceSessionsRouter( |
240 profile(), syncer::SyncableService::StartSyncFlare())); | 242 profile(), syncer::SyncableService::StartSyncFlare())); |
241 manager_.reset(new SessionsSyncManager(profile(), this, | 243 manager_.reset(new SessionsSyncManager(profile(), this, |
242 scoped_ptr<LocalSessionEventRouter>(router))); | 244 scoped_ptr<LocalSessionEventRouter>(router))); |
243 } | 245 } |
244 | 246 |
245 virtual void TearDown() OVERRIDE { | 247 virtual void TearDown() OVERRIDE { |
246 test_processor_ = NULL; | 248 test_processor_ = NULL; |
247 helper()->Reset(); | 249 helper()->Reset(); |
248 manager_.reset(); | 250 manager_.reset(); |
249 BrowserWithTestWindowTest::TearDown(); | 251 BrowserWithTestWindowTest::TearDown(); |
| 252 at_exit_.reset(); |
250 } | 253 } |
251 | 254 |
252 virtual scoped_ptr<DeviceInfo> GetLocalDeviceInfo() const OVERRIDE { | 255 virtual scoped_ptr<DeviceInfo> GetLocalDeviceInfo() const OVERRIDE { |
253 return scoped_ptr<DeviceInfo>( | 256 return scoped_ptr<DeviceInfo>( |
254 new DeviceInfo(GetLocalSyncCacheGUID(), | 257 new DeviceInfo(GetLocalSyncCacheGUID(), |
255 "Wayne Gretzky's Hacking Box", | 258 "Wayne Gretzky's Hacking Box", |
256 "Chromium 10k", | 259 "Chromium 10k", |
257 "Chrome 10k", | 260 "Chrome 10k", |
258 sync_pb::SyncEnums_DeviceType_TYPE_LINUX)); | 261 sync_pb::SyncEnums_DeviceType_TYPE_LINUX)); |
259 } | 262 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 found = true; | 306 found = true; |
304 } else { | 307 } else { |
305 ++it; | 308 ++it; |
306 } | 309 } |
307 } | 310 } |
308 EXPECT_TRUE(found); | 311 EXPECT_TRUE(found); |
309 return list; | 312 return list; |
310 } | 313 } |
311 | 314 |
312 private: | 315 private: |
| 316 scoped_ptr<base::ShadowingAtExitManager> at_exit_; |
313 scoped_ptr<SessionsSyncManager> manager_; | 317 scoped_ptr<SessionsSyncManager> manager_; |
314 SessionSyncTestHelper helper_; | 318 SessionSyncTestHelper helper_; |
315 TestSyncProcessorStub* test_processor_; | 319 TestSyncProcessorStub* test_processor_; |
316 }; | 320 }; |
317 | 321 |
318 // Test that the SyncSessionManager can properly fill in a SessionHeader. | 322 // Test that the SyncSessionManager can properly fill in a SessionHeader. |
319 TEST_F(SessionsSyncManagerTest, PopulateSessionHeader) { | 323 TEST_F(SessionsSyncManagerTest, PopulateSessionHeader) { |
320 sync_pb::SessionHeader header_s; | 324 sync_pb::SessionHeader header_s; |
321 header_s.set_client_name("Client 1"); | 325 header_s.set_client_name("Client 1"); |
322 header_s.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_WIN); | 326 header_s.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_WIN); |
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 ASSERT_FALSE(observer.notified_of_refresh()); | 1817 ASSERT_FALSE(observer.notified_of_refresh()); |
1814 InitWithNoSyncData(); | 1818 InitWithNoSyncData(); |
1815 AddTab(browser(), GURL("http://foo1")); | 1819 AddTab(browser(), GURL("http://foo1")); |
1816 EXPECT_FALSE(observer.notified_of_refresh()); | 1820 EXPECT_FALSE(observer.notified_of_refresh()); |
1817 NavigateAndCommitActiveTab(GURL("chrome://newtab/#open_tabs")); | 1821 NavigateAndCommitActiveTab(GURL("chrome://newtab/#open_tabs")); |
1818 EXPECT_TRUE(observer.notified_of_refresh()); | 1822 EXPECT_TRUE(observer.notified_of_refresh()); |
1819 } | 1823 } |
1820 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 1824 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
1821 | 1825 |
1822 } // namespace browser_sync | 1826 } // namespace browser_sync |
OLD | NEW |