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

Side by Side Diff: sync/notifier/invalidator_factory_unittest.cc

Issue 10875064: Rename SyncNotifier->Invalidator and SyncNotifierObserver->InvalidationHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to ToT for landing Created 8 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 | Annotate | Revision Log
« no previous file with comments | « sync/notifier/invalidator_factory.cc ('k') | sync/notifier/invalidator_registrar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/notifier/sync_notifier_factory.h" 5 #include "sync/notifier/invalidator_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/base/model_type.h" 17 #include "sync/internal_api/public/base/model_type.h"
18 #include "sync/notifier/fake_sync_notifier_observer.h" 18 #include "sync/notifier/fake_invalidation_handler.h"
19 #include "sync/notifier/invalidation_state_tracker.h" 19 #include "sync/notifier/invalidation_state_tracker.h"
20 #include "sync/notifier/sync_notifier.h" 20 #include "sync/notifier/invalidator.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace syncer { 23 namespace syncer {
24 namespace { 24 namespace {
25 25
26 class SyncNotifierFactoryTest : public testing::Test { 26 class InvalidatorFactoryTest : public testing::Test {
27 protected: 27 protected:
28 28
29 virtual void SetUp() OVERRIDE { 29 virtual void SetUp() OVERRIDE {
30 notifier_options_.request_context_getter = 30 notifier_options_.request_context_getter =
31 new TestURLRequestContextGetter(message_loop_.message_loop_proxy()); 31 new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
32 } 32 }
33 33
34 virtual void TearDown() OVERRIDE { 34 virtual void TearDown() OVERRIDE {
35 message_loop_.RunAllPending(); 35 message_loop_.RunAllPending();
36 EXPECT_EQ(0, fake_observer_.GetNotificationCount()); 36 EXPECT_EQ(0, fake_handler_.GetNotificationCount());
37 } 37 }
38 38
39 MessageLoop message_loop_; 39 MessageLoop message_loop_;
40 FakeSyncNotifierObserver fake_observer_; 40 FakeInvalidationHandler fake_handler_;
41 notifier::NotifierOptions notifier_options_; 41 notifier::NotifierOptions notifier_options_;
42 scoped_ptr<SyncNotifierFactory> factory_; 42 scoped_ptr<InvalidatorFactory> factory_;
43 }; 43 };
44 44
45 // Test basic creation of a NonBlockingInvalidationNotifier. 45 // Test basic creation of a NonBlockingInvalidationNotifier.
46 TEST_F(SyncNotifierFactoryTest, Basic) { 46 TEST_F(InvalidatorFactoryTest, Basic) {
47 notifier_options_.notification_method = notifier::NOTIFICATION_SERVER; 47 notifier_options_.notification_method = notifier::NOTIFICATION_SERVER;
48 SyncNotifierFactory factory( 48 InvalidatorFactory factory(
49 notifier_options_, 49 notifier_options_,
50 "test client info", 50 "test client info",
51 base::WeakPtr<InvalidationStateTracker>()); 51 base::WeakPtr<InvalidationStateTracker>());
52 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier()); 52 scoped_ptr<Invalidator> invalidator(factory.CreateInvalidator());
53 #if defined(OS_ANDROID) 53 #if defined(OS_ANDROID)
54 ASSERT_FALSE(notifier.get()); 54 ASSERT_FALSE(invalidator.get());
55 #else 55 #else
56 ASSERT_TRUE(notifier.get()); 56 ASSERT_TRUE(invalidator.get());
57 ObjectIdSet ids = ModelTypeSetToObjectIdSet(ModelTypeSet(syncer::BOOKMARKS)); 57 ObjectIdSet ids = ModelTypeSetToObjectIdSet(ModelTypeSet(syncer::BOOKMARKS));
58 notifier->RegisterHandler(&fake_observer_); 58 invalidator->RegisterHandler(&fake_handler_);
59 notifier->UpdateRegisteredIds(&fake_observer_, ids); 59 invalidator->UpdateRegisteredIds(&fake_handler_, ids);
60 notifier->UnregisterHandler(&fake_observer_); 60 invalidator->UnregisterHandler(&fake_handler_);
61 #endif 61 #endif
62 } 62 }
63 63
64 // Test basic creation of a P2PNotifier. 64 // Test basic creation of a P2PNotifier.
65 TEST_F(SyncNotifierFactoryTest, Basic_P2P) { 65 TEST_F(InvalidatorFactoryTest, Basic_P2P) {
66 notifier_options_.notification_method = notifier::NOTIFICATION_P2P; 66 notifier_options_.notification_method = notifier::NOTIFICATION_P2P;
67 SyncNotifierFactory factory( 67 InvalidatorFactory factory(
68 notifier_options_, 68 notifier_options_,
69 "test client info", 69 "test client info",
70 base::WeakPtr<InvalidationStateTracker>()); 70 base::WeakPtr<InvalidationStateTracker>());
71 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier()); 71 scoped_ptr<Invalidator> invalidator(factory.CreateInvalidator());
72 #if defined(OS_ANDROID) 72 #if defined(OS_ANDROID)
73 ASSERT_FALSE(notifier.get()); 73 ASSERT_FALSE(invalidator.get());
74 #else 74 #else
75 ASSERT_TRUE(notifier.get()); 75 ASSERT_TRUE(invalidator.get());
76 ObjectIdSet ids = ModelTypeSetToObjectIdSet(ModelTypeSet(syncer::BOOKMARKS)); 76 ObjectIdSet ids = ModelTypeSetToObjectIdSet(ModelTypeSet(syncer::BOOKMARKS));
77 notifier->RegisterHandler(&fake_observer_); 77 invalidator->RegisterHandler(&fake_handler_);
78 notifier->UpdateRegisteredIds(&fake_observer_, ids); 78 invalidator->UpdateRegisteredIds(&fake_handler_, ids);
79 notifier->UnregisterHandler(&fake_observer_); 79 invalidator->UnregisterHandler(&fake_handler_);
80 #endif 80 #endif
81 } 81 }
82 82
83 } // namespace 83 } // namespace
84 } // namespace syncer 84 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/invalidator_factory.cc ('k') | sync/notifier/invalidator_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698