Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: content/test/test_find_request_manager.cc

Issue 1891773002: Implement the basic testing infrastructure for FindRequestManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment to describe TestFindRequestManager. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/test_find_request_manager.cc
diff --git a/content/test/test_find_request_manager.cc b/content/test/test_find_request_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..06576e23f17351b20f938f86e72a6ff65ce62d0e
--- /dev/null
+++ b/content/test/test_find_request_manager.cc
@@ -0,0 +1,57 @@
+// 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 "content/test/test_find_request_manager.h"
+
+#include "content/browser/web_contents/web_contents_impl.h"
+
+namespace content {
+
+TestFindRequestManager::TestFindRequestManager(WebContentsImpl* web_contents)
+ : FindRequestManager(web_contents),
+ last_request_id_(kInvalidId),
+ last_finished_request_id_(kInvalidId),
+ waiting_request_id_(kInvalidId) {}
+
+TestFindRequestManager::~TestFindRequestManager() {}
+
+void TestFindRequestManager::Find(int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options) {
+ last_request_id_ = request_id;
+ FindRequestManager::Find(request_id, search_text, options);
+}
+
+void TestFindRequestManager::WaitForFinalReply() {
+ if (last_finished_request_id_ == last_request_id_)
+ return;
+
+ waiting_request_id_ = last_request_id_;
+ find_message_loop_runner_ = new content::MessageLoopRunner;
+ find_message_loop_runner_->Run();
+}
+
+TestFindRequestManager::FindResults TestFindRequestManager::GetFindResults() {
+ FindResults results;
+ results.request_id = last_finished_request_id_;
+ results.number_of_matches = number_of_matches_;
+ results.active_match_ordinal = active_match_ordinal_;
+ return results;
+}
+
+void TestFindRequestManager::NotifyFindReply(int request_id,
+ bool final_update) const {
+ if (final_update)
+ last_finished_request_id_ = request_id;
+
+ // If we are waiting for a final reply and this is it, stop waiting.
+ if (find_message_loop_runner_.get() &&
+ last_finished_request_id_ >= waiting_request_id_) {
+ find_message_loop_runner_->Quit();
+ }
+
+ FindRequestManager::NotifyFindReply(request_id, final_update);
+}
+
+} // namespace content
« content/test/test_find_request_manager.h ('K') | « content/test/test_find_request_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698