| 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" | 5 #include "base/location.h" |
| 6 #include "base/single_thread_task_runner.h" | 6 #include "base/single_thread_task_runner.h" |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "chrome/browser/local_discovery/privet_url_fetcher.h" | 8 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
| 9 #include "net/url_request/test_url_fetcher_factory.h" | 9 #include "net/url_request/test_url_fetcher_factory.h" |
| 10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 void RunFor(base::TimeDelta time_period) { | 108 void RunFor(base::TimeDelta time_period) { |
| 109 base::CancelableCallback<void()> callback(base::Bind( | 109 base::CancelableCallback<void()> callback(base::Bind( |
| 110 &PrivetURLFetcherTest::Stop, base::Unretained(this))); | 110 &PrivetURLFetcherTest::Stop, base::Unretained(this))); |
| 111 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 111 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 112 FROM_HERE, callback.callback(), time_period); | 112 FROM_HERE, callback.callback(), time_period); |
| 113 | 113 |
| 114 base::MessageLoop::current()->Run(); | 114 base::MessageLoop::current()->Run(); |
| 115 callback.Cancel(); | 115 callback.Cancel(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void Stop() { | 118 void Stop() { base::MessageLoop::current()->QuitWhenIdle(); } |
| 119 base::MessageLoop::current()->Quit(); | |
| 120 } | |
| 121 | 119 |
| 122 protected: | 120 protected: |
| 123 base::MessageLoop loop_; | 121 base::MessageLoop loop_; |
| 124 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 122 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 125 net::TestURLFetcherFactory fetcher_factory_; | 123 net::TestURLFetcherFactory fetcher_factory_; |
| 126 scoped_ptr<PrivetURLFetcher> privet_urlfetcher_; | 124 scoped_ptr<PrivetURLFetcher> privet_urlfetcher_; |
| 127 StrictMock<MockPrivetURLFetcherDelegate> delegate_; | 125 StrictMock<MockPrivetURLFetcherDelegate> delegate_; |
| 128 }; | 126 }; |
| 129 | 127 |
| 130 TEST_F(PrivetURLFetcherTest, FetchSuccess) { | 128 TEST_F(PrivetURLFetcherTest, FetchSuccess) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 std::string header_token; | 313 std::string header_token; |
| 316 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); | 314 ASSERT_FALSE(headers.GetHeader("X-Privet-Token", &header_token)); |
| 317 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); | 315 ASSERT_FALSE(headers.GetHeader("X-Privet-Auth", &header_token)); |
| 318 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); | 316 ASSERT_TRUE(headers.GetHeader("Authorization", &header_token)); |
| 319 ASSERT_EQ("MyAuthToken", header_token); | 317 ASSERT_EQ("MyAuthToken", header_token); |
| 320 } | 318 } |
| 321 | 319 |
| 322 } // namespace | 320 } // namespace |
| 323 | 321 |
| 324 } // namespace local_discovery | 322 } // namespace local_discovery |
| OLD | NEW |