OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <algorithm> | 5 #include <algorithm> |
6 #include <map> | 6 #include <map> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 namespace gcm { | 44 namespace gcm { |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 const char kTestExtensionName[] = "FooBar"; | 48 const char kTestExtensionName[] = "FooBar"; |
49 const char kTestingUsername[] = "user1@example.com"; | 49 const char kTestingUsername[] = "user1@example.com"; |
50 const char kTestingUsername2[] = "user2@example.com"; | 50 const char kTestingUsername2[] = "user2@example.com"; |
51 const char kTestingUsername3[] = "user3@example.com"; | 51 const char kTestingUsername3[] = "user3@example.com"; |
52 const char kTestingAppId[] = "TestApp1"; | 52 const char kTestingAppId[] = "TestApp1"; |
53 const char kTestingAppId2[] = "TestApp2"; | 53 const char kTestingAppId2[] = "TestApp2"; |
54 const char kTestingSha1Cert[] = "testing_cert1"; | |
55 const char kUserId[] = "user1"; | 54 const char kUserId[] = "user1"; |
56 const char kUserId2[] = "user2"; | 55 const char kUserId2[] = "user2"; |
57 | 56 |
58 // Helper class for asynchrnous waiting. | 57 // Helper class for asynchrnous waiting. |
59 class Waiter { | 58 class Waiter { |
60 public: | 59 public: |
61 Waiter() {} | 60 Waiter() {} |
62 virtual ~Waiter() {} | 61 virtual ~Waiter() {} |
63 | 62 |
64 // Waits until the asynchrnous operation finishes. | 63 // Waits until the asynchrnous operation finishes. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 signin_manager_->SignOut(); | 356 signin_manager_->SignOut(); |
358 waiter_->PumpIOLoop(); | 357 waiter_->PumpIOLoop(); |
359 waiter_->PumpUILoop(); | 358 waiter_->PumpUILoop(); |
360 } | 359 } |
361 | 360 |
362 void Register(const std::string& app_id, | 361 void Register(const std::string& app_id, |
363 const std::vector<std::string>& sender_ids) { | 362 const std::vector<std::string>& sender_ids) { |
364 GetGCMProfileService()->Register( | 363 GetGCMProfileService()->Register( |
365 app_id, | 364 app_id, |
366 sender_ids, | 365 sender_ids, |
367 kTestingSha1Cert, | |
368 base::Bind(&GCMProfileServiceTestConsumer::RegisterCompleted, | 366 base::Bind(&GCMProfileServiceTestConsumer::RegisterCompleted, |
369 base::Unretained(this))); | 367 base::Unretained(this))); |
370 } | 368 } |
371 | 369 |
372 void RegisterCompleted(const std::string& registration_id, | 370 void RegisterCompleted(const std::string& registration_id, |
373 GCMClient::Result result) { | 371 GCMClient::Result result) { |
374 registration_id_ = registration_id; | 372 registration_id_ = registration_id; |
375 registration_result_ = result; | 373 registration_result_ = result; |
376 waiter_->SignalCompleted(); | 374 waiter_->SignalCompleted(); |
377 } | 375 } |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 consumer()->gcm_event_router()->clear_results(); | 1362 consumer()->gcm_event_router()->clear_results(); |
1365 WaitUntilCompleted(); | 1363 WaitUntilCompleted(); |
1366 | 1364 |
1367 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, | 1365 EXPECT_EQ(FakeGCMEventRouter::MESSAGE_EVENT, |
1368 consumer()->gcm_event_router()->received_event()); | 1366 consumer()->gcm_event_router()->received_event()); |
1369 EXPECT_TRUE( | 1367 EXPECT_TRUE( |
1370 in_message5.data == consumer()->gcm_event_router()->message().data); | 1368 in_message5.data == consumer()->gcm_event_router()->message().data); |
1371 } | 1369 } |
1372 | 1370 |
1373 } // namespace gcm | 1371 } // namespace gcm |
OLD | NEW |