summaryrefslogtreecommitdiff
path: root/chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-12 14:07:37 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-17 10:29:26 +0000
commitec02ee4181c49b61fce1c8fb99292dbb8139cc90 (patch)
tree25cde714b2b71eb639d1cd53f5a22e9ba76e14ef /chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc
parentbb09965444b5bb20b096a291445170876225268d (diff)
downloadqtwebengine-chromium-ec02ee4181c49b61fce1c8fb99292dbb8139cc90.tar.gz
BASELINE: Update Chromium to 59.0.3071.134
Change-Id: Id02ef6fb2204c5fd21668a1c3e6911c83b17585a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc')
-rw-r--r--chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc b/chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc
new file mode 100644
index 00000000000..34627e0dded
--- /dev/null
+++ b/chromium/components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.cc
@@ -0,0 +1,48 @@
+// 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/subresource_filter/content/browser/async_document_subresource_filter_test_utils.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/run_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace subresource_filter {
+namespace testing {
+
+TestActivationStateCallbackReceiver::TestActivationStateCallbackReceiver() =
+ default;
+TestActivationStateCallbackReceiver::~TestActivationStateCallbackReceiver() =
+ default;
+
+base::Callback<void(ActivationState)>
+TestActivationStateCallbackReceiver::GetCallback() {
+ return base::Bind(&TestActivationStateCallbackReceiver::Callback,
+ base::Unretained(this));
+}
+
+void TestActivationStateCallbackReceiver::WaitForActivationDecision() {
+ ASSERT_EQ(0, callback_count_);
+ base::RunLoop run_loop;
+ quit_closure_ = run_loop.QuitClosure();
+ run_loop.Run();
+}
+
+void TestActivationStateCallbackReceiver::ExpectReceivedOnce(
+ const ActivationState& expected_state) const {
+ ASSERT_EQ(1, callback_count_);
+ EXPECT_EQ(expected_state, last_activation_state_);
+}
+
+void TestActivationStateCallbackReceiver::Callback(
+ ActivationState activation_state) {
+ ++callback_count_;
+ last_activation_state_ = activation_state;
+ if (quit_closure_)
+ quit_closure_.Run();
+}
+
+} // namespace testing
+} // namespace subresource_filter