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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "components/dom_distiller/core/distiller_url_fetcher.h" | 8 #include "components/dom_distiller/core/distiller_url_fetcher.h" |
9 #include "net/http/http_status_code.h" | 9 #include "net/http/http_status_code.h" |
10 #include "net/url_request/test_url_fetcher_factory.h" | 10 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const std::string& expected_response) { | 47 const std::string& expected_response) { |
48 base::MessageLoopForUI loop; | 48 base::MessageLoopForUI loop; |
49 url_fetcher_->FetchURL( | 49 url_fetcher_->FetchURL( |
50 url, | 50 url, |
51 base::Bind(&DistillerURLFetcherTest::FetcherCallback, | 51 base::Bind(&DistillerURLFetcherTest::FetcherCallback, |
52 base::Unretained(this))); | 52 base::Unretained(this))); |
53 loop.RunUntilIdle(); | 53 loop.RunUntilIdle(); |
54 CHECK_EQ(expected_response, response_); | 54 CHECK_EQ(expected_response, response_); |
55 } | 55 } |
56 | 56 |
57 scoped_ptr<dom_distiller::DistillerURLFetcher> url_fetcher_; | 57 std::unique_ptr<dom_distiller::DistillerURLFetcher> url_fetcher_; |
58 scoped_ptr<net::FakeURLFetcherFactory> factory_; | 58 std::unique_ptr<net::FakeURLFetcherFactory> factory_; |
59 std::string response_; | 59 std::string response_; |
60 }; | 60 }; |
61 | 61 |
62 TEST_F(DistillerURLFetcherTest, PopulateProto) { | 62 TEST_F(DistillerURLFetcherTest, PopulateProto) { |
63 Fetch(kTestPageA, | 63 Fetch(kTestPageA, |
64 std::string(kTestPageAResponse, sizeof(kTestPageAResponse))); | 64 std::string(kTestPageAResponse, sizeof(kTestPageAResponse))); |
65 } | 65 } |
66 | 66 |
67 TEST_F(DistillerURLFetcherTest, PopulateProtoFailedFetch) { | 67 TEST_F(DistillerURLFetcherTest, PopulateProtoFailedFetch) { |
68 // Expect the callback to contain an empty string for this URL. | 68 // Expect the callback to contain an empty string for this URL. |
69 Fetch(kTestPageB, std::string(std::string(), 0)); | 69 Fetch(kTestPageB, std::string(std::string(), 0)); |
70 } | 70 } |
OLD | NEW |