OLD | NEW |
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 Loading... |
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_for_testing(), | 139 GCMChannelStatusRequest::default_poll_interval_seconds(), |
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_for_testing(), | 151 GCMChannelStatusRequest::default_poll_interval_seconds(), |
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_for_testing() + | 159 GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60; |
160 15 * 60; | |
161 StartRequest(); | 160 StartRequest(); |
162 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds); | 161 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds); |
163 CompleteFetch(); | 162 CompleteFetch(); |
164 | 163 |
165 EXPECT_TRUE(request_callback_invoked_); | 164 EXPECT_TRUE(request_callback_invoked_); |
166 EXPECT_TRUE(enabled_); | 165 EXPECT_TRUE(enabled_); |
167 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_); | 166 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_); |
168 } | 167 } |
169 | 168 |
170 TEST_F(GCMChannelStatusRequestTest, ResponseWithShortPollInterval) { | 169 TEST_F(GCMChannelStatusRequestTest, ResponseWithShortPollInterval) { |
171 // Setting a poll interval 15 minutes shorter than the minimum interval we | 170 // Setting a poll interval 15 minutes shorter than the minimum interval we |
172 // enforce. | 171 // enforce. |
173 int poll_interval_seconds = | 172 int poll_interval_seconds = |
174 GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() - | 173 GCMChannelStatusRequest::min_poll_interval_seconds() - 15 * 60; |
175 15 * 60; | |
176 StartRequest(); | 174 StartRequest(); |
177 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds); | 175 SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds); |
178 CompleteFetch(); | 176 CompleteFetch(); |
179 | 177 |
180 EXPECT_TRUE(request_callback_invoked_); | 178 EXPECT_TRUE(request_callback_invoked_); |
181 EXPECT_TRUE(enabled_); | 179 EXPECT_TRUE(enabled_); |
182 EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds_for_testing(), | 180 EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds(), |
183 poll_interval_seconds_); | 181 poll_interval_seconds_); |
184 } | 182 } |
185 | 183 |
186 TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatusAndPollInterval) { | 184 TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatusAndPollInterval) { |
187 int poll_interval_seconds = | 185 int poll_interval_seconds = |
188 GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() + | 186 GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60; |
189 15 * 60; | |
190 StartRequest(); | 187 StartRequest(); |
191 SetResponseProtoData(GCM_DISABLED, poll_interval_seconds); | 188 SetResponseProtoData(GCM_DISABLED, poll_interval_seconds); |
192 CompleteFetch(); | 189 CompleteFetch(); |
193 | 190 |
194 EXPECT_TRUE(request_callback_invoked_); | 191 EXPECT_TRUE(request_callback_invoked_); |
195 EXPECT_FALSE(enabled_); | 192 EXPECT_FALSE(enabled_); |
196 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_); | 193 EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_); |
197 } | 194 } |
198 | 195 |
199 } // namespace gcm | 196 } // namespace gcm |
OLD | NEW |