OLD | NEW |
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 "sync/notifier/push_client_channel.h" | 5 #include "sync/notifier/push_client_channel.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 PushClientChannel::EncodeMessageForTest( | 144 PushClientChannel::EncodeMessageForTest( |
145 kMessage, | 145 kMessage, |
146 push_client_channel_.GetServiceContextForTest(), | 146 push_client_channel_.GetServiceContextForTest(), |
147 push_client_channel_.GetSchedulingHashForTest()); | 147 push_client_channel_.GetSchedulingHashForTest()); |
148 ASSERT_EQ(1u, fake_push_client_->sent_notifications().size()); | 148 ASSERT_EQ(1u, fake_push_client_->sent_notifications().size()); |
149 EXPECT_TRUE( | 149 EXPECT_TRUE( |
150 fake_push_client_->sent_notifications()[0].Equals( | 150 fake_push_client_->sent_notifications()[0].Equals( |
151 expected_notification)); | 151 expected_notification)); |
152 } | 152 } |
153 | 153 |
154 // Simulate notification state changes on the push client. It should | 154 // Simulate push client state changes on the push client. It should |
155 // propagate to the channel. | 155 // propagate to the channel. |
156 TEST_F(PushClientChannelTest, OnNotificationStateChange) { | 156 TEST_F(PushClientChannelTest, OnPushClientStateChange) { |
157 EXPECT_FALSE(connected_); | 157 EXPECT_FALSE(connected_); |
158 fake_push_client_->SimulateNotificationStateChange(true); | 158 fake_push_client_->SimulatePushClientStateChange( |
| 159 notifier::NOTIFICATIONS_ON); |
159 EXPECT_TRUE(connected_); | 160 EXPECT_TRUE(connected_); |
160 fake_push_client_->SimulateNotificationStateChange(false); | 161 fake_push_client_->SimulatePushClientStateChange( |
| 162 notifier::NOTIFICATIONS_OFF); |
| 163 EXPECT_FALSE(connected_); |
| 164 fake_push_client_->SimulatePushClientStateChange( |
| 165 notifier::NOTIFICATIONS_ON); |
| 166 EXPECT_TRUE(connected_); |
| 167 fake_push_client_->SimulatePushClientStateChange( |
| 168 notifier::CREDENTIALS_REJECTED); |
161 EXPECT_FALSE(connected_); | 169 EXPECT_FALSE(connected_); |
162 } | 170 } |
163 | 171 |
164 // Simulate an incoming notification. It should be decoded properly | 172 // Simulate an incoming notification. It should be decoded properly |
165 // by the channel. | 173 // by the channel. |
166 TEST_F(PushClientChannelTest, OnIncomingNotification) { | 174 TEST_F(PushClientChannelTest, OnIncomingNotification) { |
167 const notifier::Notification notification = | 175 const notifier::Notification notification = |
168 PushClientChannel::EncodeMessageForTest( | 176 PushClientChannel::EncodeMessageForTest( |
169 kMessage, kServiceContext, kSchedulingHash); | 177 kMessage, kServiceContext, kSchedulingHash); |
170 | 178 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 fake_push_client_->sent_notifications()[1], | 246 fake_push_client_->sent_notifications()[1], |
239 &message, &service_context, &scheduling_hash)); | 247 &message, &service_context, &scheduling_hash)); |
240 EXPECT_EQ(kMessage, message); | 248 EXPECT_EQ(kMessage, message); |
241 EXPECT_EQ(kServiceContext, service_context); | 249 EXPECT_EQ(kServiceContext, service_context); |
242 EXPECT_EQ(kSchedulingHash, scheduling_hash); | 250 EXPECT_EQ(kSchedulingHash, scheduling_hash); |
243 } | 251 } |
244 } | 252 } |
245 | 253 |
246 } // namespace | 254 } // namespace |
247 } // namespace sync_notifier | 255 } // namespace sync_notifier |
OLD | NEW |