OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/local_discovery/privet_url_fetcher.h" | 5 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
6 #include "net/url_request/test_url_fetcher_factory.h" | 6 #include "net/url_request/test_url_fetcher_factory.h" |
7 #include "net/url_request/url_request_test_util.h" | 7 #include "net/url_request/url_request_test_util.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 const char kSampleParsableJSON[] = "{ \"hello\" : 2 }"; | 22 const char kSampleParsableJSON[] = "{ \"hello\" : 2 }"; |
23 const char kSampleUnparsableJSON[] = "{ \"hello\" : }"; | 23 const char kSampleUnparsableJSON[] = "{ \"hello\" : }"; |
24 const char kSampleJSONWithError[] = "{ \"error\" : \"unittest_example\" }"; | 24 const char kSampleJSONWithError[] = "{ \"error\" : \"unittest_example\" }"; |
25 | 25 |
26 class MockPrivetURLFetcherDelegate : public PrivetURLFetcher::Delegate { | 26 class MockPrivetURLFetcherDelegate : public PrivetURLFetcher::Delegate { |
27 public: | 27 public: |
28 MockPrivetURLFetcherDelegate() : raw_mode_(false) { | 28 MockPrivetURLFetcherDelegate() : raw_mode_(false) { |
29 } | 29 } |
30 | 30 |
31 virtual ~MockPrivetURLFetcherDelegate() { | 31 ~MockPrivetURLFetcherDelegate() override { |
32 } | 32 } |
33 | 33 |
34 virtual void OnError(PrivetURLFetcher* fetcher, | 34 void OnError(PrivetURLFetcher* fetcher, |
35 PrivetURLFetcher::ErrorType error) override { | 35 PrivetURLFetcher::ErrorType error) override { |
36 OnErrorInternal(error); | 36 OnErrorInternal(error); |
37 } | 37 } |
38 | 38 |
39 MOCK_METHOD1(OnErrorInternal, void(PrivetURLFetcher::ErrorType error)); | 39 MOCK_METHOD1(OnErrorInternal, void(PrivetURLFetcher::ErrorType error)); |
40 | 40 |
41 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 41 void OnParsedJson(PrivetURLFetcher* fetcher, |
42 const base::DictionaryValue& value, | 42 const base::DictionaryValue& value, |
43 bool has_error) override { | 43 bool has_error) override { |
44 saved_value_.reset(value.DeepCopy()); | 44 saved_value_.reset(value.DeepCopy()); |
45 OnParsedJsonInternal(has_error); | 45 OnParsedJsonInternal(has_error); |
46 } | 46 } |
47 | 47 |
48 MOCK_METHOD1(OnParsedJsonInternal, void(bool has_error)); | 48 MOCK_METHOD1(OnParsedJsonInternal, void(bool has_error)); |
49 | 49 |
50 virtual void OnNeedPrivetToken( | 50 virtual void OnNeedPrivetToken( |
51 PrivetURLFetcher* fetcher, | 51 PrivetURLFetcher* fetcher, |
52 const PrivetURLFetcher::TokenCallback& callback) { | 52 const PrivetURLFetcher::TokenCallback& callback) { |
53 } | 53 } |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 std::string header_token; | 312 std::string header_token; |
313 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); | 313 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); |
314 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); | 314 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); |
315 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); | 315 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); |
316 ASSERT_EQ("MyAuthToken", header_token); | 316 ASSERT_EQ("MyAuthToken", header_token); |
317 } | 317 } |
318 | 318 |
319 } // namespace | 319 } // namespace |
320 | 320 |
321 } // namespace local_discovery | 321 } // namespace local_discovery |
OLD | NEW |