| 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/printing/cloud_print/privet_url_fetcher.h" | 5 #include "chrome/browser/printing/cloud_print/privet_url_fetcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
| 13 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using testing::StrictMock; | 18 using testing::StrictMock; |
| 18 | 19 |
| 19 namespace cloud_print { | 20 namespace cloud_print { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 106 } |
| 106 virtual ~PrivetURLFetcherTest() { | 107 virtual ~PrivetURLFetcherTest() { |
| 107 } | 108 } |
| 108 | 109 |
| 109 void RunFor(base::TimeDelta time_period) { | 110 void RunFor(base::TimeDelta time_period) { |
| 110 base::CancelableCallback<void()> callback(base::Bind( | 111 base::CancelableCallback<void()> callback(base::Bind( |
| 111 &PrivetURLFetcherTest::Stop, base::Unretained(this))); | 112 &PrivetURLFetcherTest::Stop, base::Unretained(this))); |
| 112 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 113 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 113 FROM_HERE, callback.callback(), time_period); | 114 FROM_HERE, callback.callback(), time_period); |
| 114 | 115 |
| 115 base::MessageLoop::current()->Run(); | 116 base::RunLoop().Run(); |
| 116 callback.Cancel(); | 117 callback.Cancel(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void Stop() { base::MessageLoop::current()->QuitWhenIdle(); } | 120 void Stop() { base::MessageLoop::current()->QuitWhenIdle(); } |
| 120 | 121 |
| 121 protected: | 122 protected: |
| 122 base::MessageLoop loop_; | 123 base::MessageLoop loop_; |
| 123 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 124 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 124 net::TestURLFetcherFactory fetcher_factory_; | 125 net::TestURLFetcherFactory fetcher_factory_; |
| 125 std::unique_ptr<PrivetURLFetcher> privet_urlfetcher_; | 126 std::unique_ptr<PrivetURLFetcher> privet_urlfetcher_; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 net::OK)); | 297 net::OK)); |
| 297 fetcher->set_response_code(200); | 298 fetcher->set_response_code(200); |
| 298 | 299 |
| 299 EXPECT_CALL(delegate_, OnFileInternal()); | 300 EXPECT_CALL(delegate_, OnFileInternal()); |
| 300 fetcher->delegate()->OnURLFetchComplete(fetcher); | 301 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 301 } | 302 } |
| 302 | 303 |
| 303 } // namespace | 304 } // namespace |
| 304 | 305 |
| 305 } // namespace cloud_print | 306 } // namespace cloud_print |
| OLD | NEW |