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/location.h" |
| 6 #include "base/single_thread_task_runner.h" |
5 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
6 #include "chrome/browser/local_discovery/privet_url_fetcher.h" | 8 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
7 #include "net/url_request/test_url_fetcher_factory.h" | 9 #include "net/url_request/test_url_fetcher_factory.h" |
8 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 | 13 |
12 using testing::StrictMock; | 14 using testing::StrictMock; |
13 | 15 |
14 namespace local_discovery { | 16 namespace local_discovery { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 101 |
100 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(), | 102 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(), |
101 kSamplePrivetToken); | 103 kSamplePrivetToken); |
102 } | 104 } |
103 virtual ~PrivetURLFetcherTest() { | 105 virtual ~PrivetURLFetcherTest() { |
104 } | 106 } |
105 | 107 |
106 void RunFor(base::TimeDelta time_period) { | 108 void RunFor(base::TimeDelta time_period) { |
107 base::CancelableCallback<void()> callback(base::Bind( | 109 base::CancelableCallback<void()> callback(base::Bind( |
108 &PrivetURLFetcherTest::Stop, base::Unretained(this))); | 110 &PrivetURLFetcherTest::Stop, base::Unretained(this))); |
109 base::MessageLoop::current()->PostDelayedTask( | 111 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
110 FROM_HERE, callback.callback(), time_period); | 112 FROM_HERE, callback.callback(), time_period); |
111 | 113 |
112 base::MessageLoop::current()->Run(); | 114 base::MessageLoop::current()->Run(); |
113 callback.Cancel(); | 115 callback.Cancel(); |
114 } | 116 } |
115 | 117 |
116 void Stop() { | 118 void Stop() { |
117 base::MessageLoop::current()->Quit(); | 119 base::MessageLoop::current()->Quit(); |
118 } | 120 } |
119 | 121 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 std::string header_token; | 315 std::string header_token; |
314 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); | 316 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); |
315 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); | 317 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); |
316 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); | 318 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); |
317 ASSERT_EQ("MyAuthToken", header_token); | 319 ASSERT_EQ("MyAuthToken", header_token); |
318 } | 320 } |
319 | 321 |
320 } // namespace | 322 } // namespace |
321 | 323 |
322 } // namespace local_discovery | 324 } // namespace local_discovery |
OLD | NEW |