Index: chrome/browser/browsing_data/clear_site_data_throttle_unittest.cc |
diff --git a/chrome/browser/browsing_data/clear_site_data_throttle_unittest.cc b/chrome/browser/browsing_data/clear_site_data_throttle_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0f8f8e7bec2e4c5fafa51b5c4fcea67883796181 |
--- /dev/null |
+++ b/chrome/browser/browsing_data/clear_site_data_throttle_unittest.cc |
@@ -0,0 +1,60 @@ |
+// Copyright 2016 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 "chrome/browser/browsing_data/clear_site_data_throttle.h" |
+ |
+#include <memory> |
+ |
+#include "base/message_loop/message_loop.h" |
+#include "chrome/browser/browsing_data/browsing_data_remover.h" |
+#include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
+#include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
+#include "chrome/test/base/testing_profile.h" |
+#include "content/public/test/test_browser_thread.h" |
+#include "net/url_request/url_request.h" |
+#include "net/url_request/url_request_test_util.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace { |
+ |
+class ClearSiteDataThrottleTest : public testing::Test { |
+ public: |
+ ClearSiteDataThrottleTest() |
+ : ui_thread_(content::BrowserThread::UI, &ui_loop_), |
+ io_thread_(content::BrowserThread::IO) {} |
+ |
+ void SetUp() override { |
+ remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(&profile_); |
+ } |
+ |
+ void RunTestCase(const std::string& url) { |
+ // Construct the request with given parameters. |
+ std::unique_ptr<net::URLRequest> url_request_context = |
+ profile_.GetRequestContext()->GetURLRequestContext()->CreateRequest( |
+ GURL(url), net::DEFAULT_PRIORITY, &delegate_); |
+ |
+ // Process the request. |
+ BrowsingDataRemoverCompletionObserver completion_observer(remover_); |
+ ClearSiteDataThrottle throttle(url_request_context.get()); |
+ bool defer; |
+ throttle.WillProcessResponse(&defer); |
+ completion_observer.BlockUntilCompletion(); |
+ } |
+ |
+ private: |
+ base::MessageLoop ui_loop_; |
+ content::TestBrowserThread ui_thread_; |
+ content::TestBrowserThread io_thread_; |
+ |
+ TestingProfile profile_; |
+ net::TestDelegate delegate_; |
+ |
+ BrowsingDataRemover* remover_; |
+}; |
+ |
+TEST_F(ClearSiteDataThrottleTest, Types) { |
+ RunTestCase("www.example.com"); |
+} |
+ |
+} // namespace |