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

Side by Side Diff: google_apis/gcm/gcm_client_impl_unittest.cc

Issue 226223005: Revert of Removing the mock-keychain related bool from GCMStore constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « google_apis/gcm/gcm_client_impl.cc ('k') | google_apis/gcm/tools/mcs_probe.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 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 "google_apis/gcm/gcm_client_impl.h" 5 #include "google_apis/gcm/gcm_client_impl.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/simple_test_clock.h" 10 #include "base/test/simple_test_clock.h"
11 #include "components/os_crypt/os_crypt.h" 11 #include "components/os_crypt/os_crypt.h"
12 #include "google_apis/gcm/base/mcs_message.h" 12 #include "google_apis/gcm/base/mcs_message.h"
13 #include "google_apis/gcm/base/mcs_util.h" 13 #include "google_apis/gcm/base/mcs_util.h"
14 #include "google_apis/gcm/engine/fake_connection_factory.h" 14 #include "google_apis/gcm/engine/fake_connection_factory.h"
15 #include "google_apis/gcm/engine/fake_connection_handler.h" 15 #include "google_apis/gcm/engine/fake_connection_handler.h"
16 #include "google_apis/gcm/engine/gcm_store_impl.h"
17 #include "google_apis/gcm/protocol/android_checkin.pb.h" 16 #include "google_apis/gcm/protocol/android_checkin.pb.h"
18 #include "google_apis/gcm/protocol/checkin.pb.h" 17 #include "google_apis/gcm/protocol/checkin.pb.h"
19 #include "google_apis/gcm/protocol/mcs.pb.h" 18 #include "google_apis/gcm/protocol/mcs.pb.h"
20 #include "net/url_request/test_url_fetcher_factory.h" 19 #include "net/url_request/test_url_fetcher_factory.h"
21 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
22 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 namespace gcm { 24 namespace gcm {
26 25
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 message.GetProtobuf())); 110 message.GetProtobuf()));
112 } 111 }
113 } 112 }
114 113
115 class FakeGCMInternalsBuilder : public GCMInternalsBuilder { 114 class FakeGCMInternalsBuilder : public GCMInternalsBuilder {
116 public: 115 public:
117 FakeGCMInternalsBuilder(); 116 FakeGCMInternalsBuilder();
118 virtual ~FakeGCMInternalsBuilder(); 117 virtual ~FakeGCMInternalsBuilder();
119 118
120 virtual scoped_ptr<base::Clock> BuildClock() OVERRIDE; 119 virtual scoped_ptr<base::Clock> BuildClock() OVERRIDE;
121 virtual scoped_ptr<GCMStore> BuildGCMStore(
122 const base::FilePath& path,
123 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
124 OVERRIDE;
125 virtual scoped_ptr<MCSClient> BuildMCSClient( 120 virtual scoped_ptr<MCSClient> BuildMCSClient(
126 const std::string& version, 121 const std::string& version,
127 base::Clock* clock, 122 base::Clock* clock,
128 ConnectionFactory* connection_factory, 123 ConnectionFactory* connection_factory,
129 GCMStore* gcm_store) OVERRIDE; 124 GCMStore* gcm_store) OVERRIDE;
130 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( 125 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory(
131 const std::vector<GURL>& endpoints, 126 const std::vector<GURL>& endpoints,
132 const net::BackoffEntry::Policy& backoff_policy, 127 const net::BackoffEntry::Policy& backoff_policy,
133 scoped_refptr<net::HttpNetworkSession> network_session, 128 scoped_refptr<net::HttpNetworkSession> network_session,
134 net::NetLog* net_log) OVERRIDE; 129 net::NetLog* net_log) OVERRIDE;
135 }; 130 };
136 131
137 FakeGCMInternalsBuilder::FakeGCMInternalsBuilder() {} 132 FakeGCMInternalsBuilder::FakeGCMInternalsBuilder() {}
138 133
139 FakeGCMInternalsBuilder::~FakeGCMInternalsBuilder() {} 134 FakeGCMInternalsBuilder::~FakeGCMInternalsBuilder() {}
140 135
141 scoped_ptr<base::Clock> FakeGCMInternalsBuilder::BuildClock() { 136 scoped_ptr<base::Clock> FakeGCMInternalsBuilder::BuildClock() {
142 return make_scoped_ptr<base::Clock>(new base::SimpleTestClock()); 137 return make_scoped_ptr<base::Clock>(new base::SimpleTestClock());
143 } 138 }
144 139
145 scoped_ptr<GCMStore> FakeGCMInternalsBuilder::BuildGCMStore(
146 const base::FilePath& path,
147 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) {
148 #if defined(OS_MACOSX)
149 OSCrypt::UseMockKeychain(true);
150 #endif
151 return make_scoped_ptr<GCMStore>(
152 new GCMStoreImpl(path, blocking_task_runner));
153 }
154
155 scoped_ptr<MCSClient> FakeGCMInternalsBuilder::BuildMCSClient( 140 scoped_ptr<MCSClient> FakeGCMInternalsBuilder::BuildMCSClient(
156 const std::string& version, 141 const std::string& version,
157 base::Clock* clock, 142 base::Clock* clock,
158 ConnectionFactory* connection_factory, 143 ConnectionFactory* connection_factory,
159 GCMStore* gcm_store) { 144 GCMStore* gcm_store) {
160 return make_scoped_ptr<MCSClient>(new FakeMCSClient(clock, 145 return make_scoped_ptr<MCSClient>(new FakeMCSClient(clock,
161 connection_factory, 146 connection_factory,
162 gcm_store)); 147 gcm_store));
163 } 148 }
164 149
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); 589 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent());
605 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); 590 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id());
606 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); 591 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from());
607 EXPECT_EQ(kSender, mcs_client()->last_data_message_stanza().to()); 592 EXPECT_EQ(kSender, mcs_client()->last_data_message_stanza().to());
608 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); 593 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key());
609 EXPECT_EQ("value", 594 EXPECT_EQ("value",
610 mcs_client()->last_data_message_stanza().app_data(0).value()); 595 mcs_client()->last_data_message_stanza().app_data(0).value());
611 } 596 }
612 597
613 } // namespace gcm 598 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/gcm_client_impl.cc ('k') | google_apis/gcm/tools/mcs_probe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698