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

Side by Side Diff: components/gcm_driver/gcm_channel_status_request_unittest.cc

Issue 582913003: Revert of Add GCMChannelStatusSyncer to schedule requests and enable/disable GCM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "components/gcm_driver/gcm_channel_status_request.h" 6 #include "components/gcm_driver/gcm_channel_status_request.h"
7 #include "components/gcm_driver/proto/gcm_channel_status.pb.h" 7 #include "components/gcm_driver/proto/gcm_channel_status.pb.h"
8 #include "net/url_request/test_url_fetcher_factory.h" 8 #include "net/url_request/test_url_fetcher_factory.h"
9 #include "net/url_request/url_request_test_util.h" 9 #include "net/url_request/url_request_test_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatus) { 131 TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatus) {
132 StartRequest(); 132 StartRequest();
133 SetResponseProtoData(GCM_DISABLED, 0); 133 SetResponseProtoData(GCM_DISABLED, 0);
134 CompleteFetch(); 134 CompleteFetch();
135 135
136 EXPECT_TRUE(request_callback_invoked_); 136 EXPECT_TRUE(request_callback_invoked_);
137 EXPECT_FALSE(enabled_); 137 EXPECT_FALSE(enabled_);
138 EXPECT_EQ( 138 EXPECT_EQ(
139 GCMChannelStatusRequest::default_poll_interval_seconds(), 139 GCMChannelStatusRequest::default_poll_interval_seconds_for_testing(),
140 poll_interval_seconds_); 140 poll_interval_seconds_);
141 } 141 }
142 142
143 TEST_F(GCMChannelStatusRequestTest, ResponseWithEnabledStatus) { 143 TEST_F(GCMChannelStatusRequestTest, ResponseWithEnabledStatus) {
144 StartRequest(); 144 StartRequest();
145 SetResponseProtoData(GCM_ENABLED, 0); 145 SetResponseProtoData(GCM_ENABLED, 0);
146 CompleteFetch(); 146 CompleteFetch();
147 147
148 EXPECT_TRUE(request_callback_invoked_); 148 EXPECT_TRUE(request_callback_invoked_);
149 EXPECT_TRUE(enabled_); 149 EXPECT_TRUE(enabled_);
150 EXPECT_EQ( 150 EXPECT_EQ(
151 GCMChannelStatusRequest::default_poll_interval_seconds(), 151 GCMChannelStatusRequest::default_poll_interval_seconds_for_testing(),
152 poll_interval_seconds_); 152 poll_interval_seconds_);
153 } 153 }
154 154
155 TEST_F(GCMChannelStatusRequestTest, ResponseWithPollInterval) { 155 TEST_F(GCMChannelStatusRequestTest, ResponseWithPollInterval) {
156 // Setting a poll interval 15 minutes longer than the minimum interval we 156 // Setting a poll interval 15 minutes longer than the minimum interval we
157 // enforce. 157 // enforce.
158 int poll_interval_seconds = 158 int poll_interval_seconds =
159 GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60; 159 GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() +
160 15 * 60;
160 StartRequest(); 161 StartRequest();
161 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds); 162 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds);
162 CompleteFetch(); 163 CompleteFetch();
163 164
164 EXPECT_TRUE(request_callback_invoked_); 165 EXPECT_TRUE(request_callback_invoked_);
165 EXPECT_TRUE(enabled_); 166 EXPECT_TRUE(enabled_);
166 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_); 167 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_);
167 } 168 }
168 169
169 TEST_F(GCMChannelStatusRequestTest, ResponseWithShortPollInterval) { 170 TEST_F(GCMChannelStatusRequestTest, ResponseWithShortPollInterval) {
170 // Setting a poll interval 15 minutes shorter than the minimum interval we 171 // Setting a poll interval 15 minutes shorter than the minimum interval we
171 // enforce. 172 // enforce.
172 int poll_interval_seconds = 173 int poll_interval_seconds =
173 GCMChannelStatusRequest::min_poll_interval_seconds() - 15 * 60; 174 GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() -
175 15 * 60;
174 StartRequest(); 176 StartRequest();
175 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds); 177 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds);
176 CompleteFetch(); 178 CompleteFetch();
177 179
178 EXPECT_TRUE(request_callback_invoked_); 180 EXPECT_TRUE(request_callback_invoked_);
179 EXPECT_TRUE(enabled_); 181 EXPECT_TRUE(enabled_);
180 EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds(), 182 EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds_for_testing(),
181 poll_interval_seconds_); 183 poll_interval_seconds_);
182 } 184 }
183 185
184 TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatusAndPollInterval) { 186 TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatusAndPollInterval) {
185 int poll_interval_seconds = 187 int poll_interval_seconds =
186 GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60; 188 GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() +
189 15 * 60;
187 StartRequest(); 190 StartRequest();
188 SetResponseProtoData(GCM_DISABLED, poll_interval_seconds); 191 SetResponseProtoData(GCM_DISABLED, poll_interval_seconds);
189 CompleteFetch(); 192 CompleteFetch();
190 193
191 EXPECT_TRUE(request_callback_invoked_); 194 EXPECT_TRUE(request_callback_invoked_);
192 EXPECT_FALSE(enabled_); 195 EXPECT_FALSE(enabled_);
193 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_); 196 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_);
194 } 197 }
195 198
196 } // namespace gcm 199 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_channel_status_request.cc ('k') | components/gcm_driver/gcm_channel_status_syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698