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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
11 #include "google_apis/gcm/engine/unregistration_request.h" | 11 #include "google_apis/gcm/engine/unregistration_request.h" |
12 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 12 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
13 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
14 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace gcm { | 17 namespace gcm { |
18 | 18 |
19 namespace { | 19 namespace { |
20 const uint64 kAndroidId = 42UL; | 20 const uint64 kAndroidId = 42UL; |
21 const char kLoginHeader[] = "AidLogin"; | 21 const char kLoginHeader[] = "AidLogin"; |
22 const char kAppId[] = "TestAppId"; | 22 const char kAppId[] = "TestAppId"; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const std::string& response_body); | 66 const std::string& response_body); |
67 void CompleteFetch(); | 67 void CompleteFetch(); |
68 | 68 |
69 protected: | 69 protected: |
70 bool callback_called_; | 70 bool callback_called_; |
71 UnregistrationRequest::Status status_; | 71 UnregistrationRequest::Status status_; |
72 scoped_ptr<UnregistrationRequest> request_; | 72 scoped_ptr<UnregistrationRequest> request_; |
73 base::MessageLoop message_loop_; | 73 base::MessageLoop message_loop_; |
74 net::TestURLFetcherFactory url_fetcher_factory_; | 74 net::TestURLFetcherFactory url_fetcher_factory_; |
75 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 75 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
76 GCMStatsRecorder recorder_; | 76 FakeGCMStatsRecorder recorder_; |
77 }; | 77 }; |
78 | 78 |
79 UnregistrationRequestTest::UnregistrationRequestTest() | 79 UnregistrationRequestTest::UnregistrationRequestTest() |
80 : callback_called_(false), | 80 : callback_called_(false), |
81 status_(UnregistrationRequest::UNREGISTRATION_STATUS_COUNT), | 81 status_(UnregistrationRequest::UNREGISTRATION_STATUS_COUNT), |
82 url_request_context_getter_(new net::TestURLRequestContextGetter( | 82 url_request_context_getter_(new net::TestURLRequestContextGetter( |
83 message_loop_.message_loop_proxy())) {} | 83 message_loop_.message_loop_proxy())) {} |
84 | 84 |
85 UnregistrationRequestTest::~UnregistrationRequestTest() {} | 85 UnregistrationRequestTest::~UnregistrationRequestTest() {} |
86 | 86 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 EXPECT_FALSE(callback_called_); | 286 EXPECT_FALSE(callback_called_); |
287 | 287 |
288 SetResponseStatusAndString(net::HTTP_OK, kDeletedAppId); | 288 SetResponseStatusAndString(net::HTTP_OK, kDeletedAppId); |
289 CompleteFetch(); | 289 CompleteFetch(); |
290 | 290 |
291 EXPECT_TRUE(callback_called_); | 291 EXPECT_TRUE(callback_called_); |
292 EXPECT_EQ(UnregistrationRequest::SUCCESS, status_); | 292 EXPECT_EQ(UnregistrationRequest::SUCCESS, status_); |
293 } | 293 } |
294 | 294 |
295 } // namespace gcm | 295 } // namespace gcm |
OLD | NEW |