Index: components/payments/payment_manifest_downloader_test.cc |
diff --git a/components/payments/payment_manifest_downloader_test.cc b/components/payments/payment_manifest_downloader_test.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f0b3e84dbb95da943967ebc290af7e0e98c28db6 |
--- /dev/null |
+++ b/components/payments/payment_manifest_downloader_test.cc |
@@ -0,0 +1,57 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/payments/payment_manifest_downloader.h" |
+ |
+#include "base/macros.h" |
+#include "base/threading/thread_task_runner_handle.h" |
+#include "content/public/test/test_browser_thread_bundle.h" |
+#include "net/url_request/test_url_fetcher_factory.h" |
+#include "net/url_request/url_fetcher.h" |
+#include "net/url_request/url_request_test_util.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace payments { |
+namespace { |
+ |
+class PaymentManifestDownloaderTest |
+ : public testing::Test, |
+ public PaymentManifestDownloader::Delegate { |
+ public: |
+ PaymentManifestDownloaderTest() |
+ : context_(new net::TestURLRequestContextGetter( |
+ base::ThreadTaskRunnerHandle::Get())), |
+ downloader_(context_, "https://bobpay.com", this) { |
+ downloader_.Download(); |
+ } |
+ |
+ ~PaymentManifestDownloaderTest() override {} |
+ |
+ // PaymentManifestDownloader::Delegate |
+ MOCK_METHOD1(OnManifestDownloadSuccess, void(const std::string& content)); |
+ MOCK_METHOD0(OnManifestDownloadFailure, void()); |
+ |
+ net::TestURLFetcher* fetcher() { |
+ return factory_.GetFetcherByID(0); |
+ } |
+ |
+ private: |
+ content::TestBrowserThreadBundle thread_bundle_; |
+ net::TestURLFetcherFactory factory_; |
+ scoped_refptr<net::TestURLRequestContextGetter> context_; |
+ PaymentManifestDownloader downloader_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PaymentManifestDownloaderTest); |
+}; |
+ |
+TEST_F(PaymentManifestDownloaderTest, HttpHeadResponse404IsFailure) { |
+ EXPECT_CALL(*this, OnManifestDownloadFailure()); |
+ |
+ fetcher()->set_response_code(404); |
+ fetcher()->delegate()->OnURLFetchComplete(fetcher()); |
+} |
+ |
+} // namespace |
+} // namespace payments |