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

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

Issue 9602026: [Sync] Remove dependencies on BrowserThread from sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/sync/notifier/non_blocking_invalidation_notifier_unittest.cc » ('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 "chrome/browser/sync/notifier/invalidation_notifier.h" 5 #include "chrome/browser/sync/notifier/invalidation_notifier.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" 9 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h"
10 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" 10 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h"
11 #include "chrome/browser/sync/syncable/model_type.h" 11 #include "chrome/browser/sync/syncable/model_type.h"
12 #include "chrome/browser/sync/syncable/model_type_payload_map.h" 12 #include "chrome/browser/sync/syncable/model_type_payload_map.h"
13 #include "chrome/browser/sync/util/weak_handle.h" 13 #include "chrome/browser/sync/util/weak_handle.h"
14 #include "content/test/test_browser_thread.h"
15 #include "jingle/notifier/base/fake_base_task.h" 14 #include "jingle/notifier/base/fake_base_task.h"
16 #include "jingle/notifier/base/notifier_options.h" 15 #include "jingle/notifier/base/notifier_options.h"
17 #include "net/base/cert_verifier.h" 16 #include "net/base/cert_verifier.h"
18 #include "net/base/host_resolver.h" 17 #include "net/base/host_resolver.h"
19 #include "net/url_request/url_request_test_util.h" 18 #include "net/url_request/url_request_test_util.h"
20 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
22 21
23 namespace sync_notifier { 22 namespace sync_notifier {
24 23
25 namespace { 24 namespace {
26 25
27 using ::testing::InSequence; 26 using ::testing::InSequence;
28 using ::testing::StrictMock; 27 using ::testing::StrictMock;
29 using content::BrowserThread;
30 28
31 class InvalidationNotifierTest : public testing::Test { 29 class InvalidationNotifierTest : public testing::Test {
32 public:
33 InvalidationNotifierTest() : io_thread_(BrowserThread::IO, &message_loop_) {}
34
35 protected: 30 protected:
36 virtual void SetUp() { 31 virtual void SetUp() {
37 notifier::NotifierOptions notifier_options; 32 notifier::NotifierOptions notifier_options;
38 // Note: URLRequestContextGetters are ref-counted. 33 // Note: URLRequestContextGetters are ref-counted.
39 notifier_options.request_context_getter = 34 notifier_options.request_context_getter =
40 new TestURLRequestContextGetter( 35 new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
41 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
42 invalidation_notifier_.reset( 36 invalidation_notifier_.reset(
43 new InvalidationNotifier( 37 new InvalidationNotifier(
44 notifier_options, 38 notifier_options,
45 InvalidationVersionMap(), 39 InvalidationVersionMap(),
46 browser_sync::MakeWeakHandle( 40 browser_sync::MakeWeakHandle(
47 base::WeakPtr<InvalidationVersionTracker>()), 41 base::WeakPtr<InvalidationVersionTracker>()),
48 "fake_client_info")); 42 "fake_client_info"));
49 invalidation_notifier_->AddObserver(&mock_observer_); 43 invalidation_notifier_->AddObserver(&mock_observer_);
50 } 44 }
51 45
52 virtual void TearDown() { 46 virtual void TearDown() {
53 invalidation_notifier_->RemoveObserver(&mock_observer_); 47 invalidation_notifier_->RemoveObserver(&mock_observer_);
54 invalidation_notifier_.reset(); 48 invalidation_notifier_.reset();
55 message_loop_.RunAllPending(); 49 message_loop_.RunAllPending();
56 } 50 }
57 51
58 MessageLoop message_loop_; 52 MessageLoop message_loop_;
59 scoped_ptr<InvalidationNotifier> invalidation_notifier_; 53 scoped_ptr<InvalidationNotifier> invalidation_notifier_;
60 StrictMock<MockSyncNotifierObserver> mock_observer_; 54 StrictMock<MockSyncNotifierObserver> mock_observer_;
61 notifier::FakeBaseTask fake_base_task_; 55 notifier::FakeBaseTask fake_base_task_;
62 // Since this test calls HostResolver code, we need an IO thread.
63 content::TestBrowserThread io_thread_;
64 }; 56 };
65 57
66 TEST_F(InvalidationNotifierTest, Basic) { 58 TEST_F(InvalidationNotifierTest, Basic) {
67 InSequence dummy; 59 InSequence dummy;
68 60
69 syncable::ModelTypePayloadMap type_payloads; 61 syncable::ModelTypePayloadMap type_payloads;
70 type_payloads[syncable::PREFERENCES] = "payload"; 62 type_payloads[syncable::PREFERENCES] = "payload";
71 type_payloads[syncable::BOOKMARKS] = ""; 63 type_payloads[syncable::BOOKMARKS] = "";
72 type_payloads[syncable::AUTOFILL] = ""; 64 type_payloads[syncable::AUTOFILL] = "";
73 65
(...skipping 18 matching lines...) Expand all
92 // Shouldn't trigger notification state change. 84 // Shouldn't trigger notification state change.
93 invalidation_notifier_->OnDisconnect(); 85 invalidation_notifier_->OnDisconnect();
94 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr()); 86 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr());
95 87
96 invalidation_notifier_->OnSessionStatusChanged(false); 88 invalidation_notifier_->OnSessionStatusChanged(false);
97 } 89 }
98 90
99 } // namespace 91 } // namespace
100 92
101 } // namespace sync_notifier 93 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/notifier/non_blocking_invalidation_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698