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

Side by Side Diff: chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc

Issue 9550009: [Sync] Move dependency on Chrome switches from SyncNotifierFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 8 years, 9 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
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 "chrome/browser/sync/notifier/sync_notifier_factory.h" 5 #include "chrome/browser/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 "chrome/browser/sync/notifier/invalidation_version_tracker.h" 14 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h"
15 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" 15 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h"
16 #include "chrome/browser/sync/notifier/sync_notifier.h" 16 #include "chrome/browser/sync/notifier/sync_notifier.h"
17 #include "chrome/browser/sync/syncable/model_type.h" 17 #include "chrome/browser/sync/syncable/model_type.h"
18 #include "chrome/browser/sync/syncable/model_type_payload_map.h" 18 #include "chrome/browser/sync/syncable/model_type_payload_map.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "jingle/notifier/base/notification_method.h"
20 #include "jingle/notifier/base/notifier_options.h"
20 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 namespace sync_notifier { 25 namespace sync_notifier {
25 namespace { 26 namespace {
26 27
27 using ::testing::Mock; 28 using ::testing::Mock;
28 using ::testing::NiceMock; 29 using ::testing::NiceMock;
29 using ::testing::StrictMock; 30 using ::testing::StrictMock;
30 31
31 class SyncNotifierFactoryTest : public testing::Test { 32 class SyncNotifierFactoryTest : public testing::Test {
32 protected: 33 protected:
33 SyncNotifierFactoryTest()
34 : command_line_(CommandLine::NO_PROGRAM) {}
35 virtual ~SyncNotifierFactoryTest() {}
36 34
37 virtual void SetUp() OVERRIDE { 35 virtual void SetUp() OVERRIDE {
38 factory_.reset(new SyncNotifierFactory( 36 notifier_options_.request_context_getter =
39 "fake_client_info", 37 new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
40 new TestURLRequestContextGetter(message_loop_.message_loop_proxy()),
41 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
42 command_line_));
43 message_loop_.RunAllPending();
44 } 38 }
45 39
46 virtual void TearDown() OVERRIDE { 40 virtual void TearDown() OVERRIDE {
47 Mock::VerifyAndClearExpectations(&mock_observer_); 41 Mock::VerifyAndClearExpectations(&mock_observer_);
48 message_loop_.RunAllPending(); 42 message_loop_.RunAllPending();
49 command_line_ = CommandLine(CommandLine::NO_PROGRAM);
50 } 43 }
51 44
52 MessageLoop message_loop_; 45 MessageLoop message_loop_;
53 StrictMock<MockSyncNotifierObserver> mock_observer_; 46 StrictMock<MockSyncNotifierObserver> mock_observer_;
47 notifier::NotifierOptions notifier_options_;
54 scoped_ptr<SyncNotifierFactory> factory_; 48 scoped_ptr<SyncNotifierFactory> factory_;
55 CommandLine command_line_;
56 }; 49 };
57 50
58 // Test basic creation of a NonBlockingInvalidationNotifier. 51 // Test basic creation of a NonBlockingInvalidationNotifier.
59 TEST_F(SyncNotifierFactoryTest, Basic) { 52 TEST_F(SyncNotifierFactoryTest, Basic) {
60 scoped_ptr<SyncNotifier> notifier(factory_->CreateSyncNotifier()); 53 notifier_options_.notification_method = notifier::NOTIFICATION_SERVER;
54 SyncNotifierFactory factory(
55 notifier_options_,
56 "test client info",
57 base::WeakPtr<sync_notifier::InvalidationVersionTracker>());
58 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier());
61 ASSERT_TRUE(notifier.get()); 59 ASSERT_TRUE(notifier.get());
62 notifier->AddObserver(&mock_observer_); 60 notifier->AddObserver(&mock_observer_);
63 notifier->RemoveObserver(&mock_observer_); 61 notifier->RemoveObserver(&mock_observer_);
64 } 62 }
65 63
66 // Test basic creation of a P2PNotifier. 64 // Test basic creation of a P2PNotifier.
67 TEST_F(SyncNotifierFactoryTest, Basic_P2P) { 65 TEST_F(SyncNotifierFactoryTest, Basic_P2P) {
68 command_line_.AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p"); 66 notifier_options_.notification_method = notifier::NOTIFICATION_P2P;
69 scoped_ptr<SyncNotifier> notifier(factory_->CreateSyncNotifier()); 67 SyncNotifierFactory factory(
68 notifier_options_,
69 "test client info",
70 base::WeakPtr<sync_notifier::InvalidationVersionTracker>());
71 scoped_ptr<SyncNotifier> notifier(factory.CreateSyncNotifier());
70 ASSERT_TRUE(notifier.get()); 72 ASSERT_TRUE(notifier.get());
71 notifier->AddObserver(&mock_observer_); 73 notifier->AddObserver(&mock_observer_);
72 notifier->RemoveObserver(&mock_observer_); 74 notifier->RemoveObserver(&mock_observer_);
73 } 75 }
74 76
75 } // namespace 77 } // namespace
76 } // namespace sync_notifier 78 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/sync_notifier_factory.cc ('k') | chrome/browser/sync/test/integration/sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698