| 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 "base/thread_task_runner_handle.h" |
| 5 #include "chrome/browser/local_discovery/privet_url_fetcher.h" | 6 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
| 6 #include "net/url_request/test_url_fetcher_factory.h" | 7 #include "net/url_request/test_url_fetcher_factory.h" |
| 7 #include "net/url_request/url_request_test_util.h" | 8 #include "net/url_request/url_request_test_util.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 using testing::StrictMock; | 12 using testing::StrictMock; |
| 12 | 13 |
| 13 namespace local_discovery { | 14 namespace local_discovery { |
| 14 | 15 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 std::string GetAuthToken() { return "MyAuthToken"; } | 82 std::string GetAuthToken() { return "MyAuthToken"; } |
| 82 | 83 |
| 83 private: | 84 private: |
| 84 scoped_ptr<base::DictionaryValue> saved_value_; | 85 scoped_ptr<base::DictionaryValue> saved_value_; |
| 85 bool raw_mode_; | 86 bool raw_mode_; |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 class PrivetURLFetcherTest : public ::testing::Test { | 89 class PrivetURLFetcherTest : public ::testing::Test { |
| 89 public: | 90 public: |
| 90 PrivetURLFetcherTest() { | 91 PrivetURLFetcherTest() { |
| 91 request_context_= new net::TestURLRequestContextGetter( | 92 request_context_ = new net::TestURLRequestContextGetter( |
| 92 base::MessageLoopProxy::current()); | 93 base::ThreadTaskRunnerHandle::Get()); |
| 93 privet_urlfetcher_.reset(new PrivetURLFetcher( | 94 privet_urlfetcher_.reset(new PrivetURLFetcher( |
| 94 GURL(kSamplePrivetURL), | 95 GURL(kSamplePrivetURL), |
| 95 net::URLFetcher::POST, | 96 net::URLFetcher::POST, |
| 96 request_context_.get(), | 97 request_context_.get(), |
| 97 &delegate_)); | 98 &delegate_)); |
| 98 | 99 |
| 99 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(), | 100 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(), |
| 100 kSamplePrivetToken); | 101 kSamplePrivetToken); |
| 101 } | 102 } |
| 102 virtual ~PrivetURLFetcherTest() { | 103 virtual ~PrivetURLFetcherTest() { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 std::string header_token; | 313 std::string header_token; |
| 313 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); | 314 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); |
| 314 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); | 315 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); |
| 315 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); | 316 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); |
| 316 ASSERT_EQ("MyAuthToken", header_token); | 317 ASSERT_EQ("MyAuthToken", header_token); |
| 317 } | 318 } |
| 318 | 319 |
| 319 } // namespace | 320 } // namespace |
| 320 | 321 |
| 321 } // namespace local_discovery | 322 } // namespace local_discovery |
| OLD | NEW |