| OLD | NEW |
| 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 "sync/notifier/sync_notifier_factory.h" | 5 #include "sync/notifier/sync_notifier_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "jingle/notifier/base/notification_method.h" | 14 #include "jingle/notifier/base/notification_method.h" |
| 15 #include "jingle/notifier/base/notifier_options.h" | 15 #include "jingle/notifier/base/notifier_options.h" |
| 16 #include "net/url_request/url_request_test_util.h" | 16 #include "net/url_request/url_request_test_util.h" |
| 17 #include "sync/internal_api/public/syncable/model_type.h" | 17 #include "sync/internal_api/public/syncable/model_type.h" |
| 18 #include "sync/internal_api/public/syncable/model_type_payload_map.h" | 18 #include "sync/internal_api/public/syncable/model_type_payload_map.h" |
| 19 #include "sync/notifier/invalidation_state_tracker.h" | 19 #include "sync/notifier/invalidation_state_tracker.h" |
| 20 #include "sync/notifier/mock_sync_notifier_observer.h" | 20 #include "sync/notifier/mock_sync_notifier_observer.h" |
| 21 #include "sync/notifier/sync_notifier.h" | 21 #include "sync/notifier/sync_notifier.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 namespace csync { | 25 namespace syncer { |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 using ::testing::Mock; | 28 using ::testing::Mock; |
| 29 using ::testing::NiceMock; | 29 using ::testing::NiceMock; |
| 30 using ::testing::StrictMock; | 30 using ::testing::StrictMock; |
| 31 | 31 |
| 32 class SyncNotifierFactoryTest : public testing::Test { | 32 class SyncNotifierFactoryTest : public testing::Test { |
| 33 protected: | 33 protected: |
| 34 | 34 |
| 35 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 notifier::NotifierOptions notifier_options_; | 47 notifier::NotifierOptions notifier_options_; |
| 48 scoped_ptr<SyncNotifierFactory> factory_; | 48 scoped_ptr<SyncNotifierFactory> factory_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // Test basic creation of a NonBlockingInvalidationNotifier. | 51 // Test basic creation of a NonBlockingInvalidationNotifier. |
| 52 TEST_F(SyncNotifierFactoryTest, Basic) { | 52 TEST_F(SyncNotifierFactoryTest, Basic) { |
| 53 notifier_options_.notification_method = notifier::NOTIFICATION_SERVER; | 53 notifier_options_.notification_method = notifier::NOTIFICATION_SERVER; |
| 54 SyncNotifierFactory factory( | 54 SyncNotifierFactory factory( |
| 55 notifier_options_, | 55 notifier_options_, |
| 56 "test client info", | 56 "test client info", |
| 57 base::WeakPtr<csync::InvalidationStateTracker>()); | 57 base::WeakPtr<syncer::InvalidationStateTracker>()); |
| 58 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier()); | 58 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier()); |
| 59 #if defined(OS_ANDROID) | 59 #if defined(OS_ANDROID) |
| 60 ASSERT_FALSE(notifier.get()); | 60 ASSERT_FALSE(notifier.get()); |
| 61 #else | 61 #else |
| 62 ASSERT_TRUE(notifier.get()); | 62 ASSERT_TRUE(notifier.get()); |
| 63 notifier->AddObserver(&mock_observer_); | 63 notifier->AddObserver(&mock_observer_); |
| 64 notifier->RemoveObserver(&mock_observer_); | 64 notifier->RemoveObserver(&mock_observer_); |
| 65 #endif | 65 #endif |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Test basic creation of a P2PNotifier. | 68 // Test basic creation of a P2PNotifier. |
| 69 TEST_F(SyncNotifierFactoryTest, Basic_P2P) { | 69 TEST_F(SyncNotifierFactoryTest, Basic_P2P) { |
| 70 notifier_options_.notification_method = notifier::NOTIFICATION_P2P; | 70 notifier_options_.notification_method = notifier::NOTIFICATION_P2P; |
| 71 SyncNotifierFactory factory( | 71 SyncNotifierFactory factory( |
| 72 notifier_options_, | 72 notifier_options_, |
| 73 "test client info", | 73 "test client info", |
| 74 base::WeakPtr<csync::InvalidationStateTracker>()); | 74 base::WeakPtr<syncer::InvalidationStateTracker>()); |
| 75 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier()); | 75 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier()); |
| 76 #if defined(OS_ANDROID) | 76 #if defined(OS_ANDROID) |
| 77 ASSERT_FALSE(notifier.get()); | 77 ASSERT_FALSE(notifier.get()); |
| 78 #else | 78 #else |
| 79 ASSERT_TRUE(notifier.get()); | 79 ASSERT_TRUE(notifier.get()); |
| 80 notifier->AddObserver(&mock_observer_); | 80 notifier->AddObserver(&mock_observer_); |
| 81 notifier->RemoveObserver(&mock_observer_); | 81 notifier->RemoveObserver(&mock_observer_); |
| 82 #endif | 82 #endif |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 } // namespace csync | 86 } // namespace syncer |
| OLD | NEW |