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

Unified Diff: content/test/test_find_request_manager.h

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.h
diff --git a/content/test/test_find_request_manager.h b/content/test/test_find_request_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..1fad3782e496050cb5ffea2d5f5e68bda5ce9766
--- /dev/null
+++ b/content/test/test_find_request_manager.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef CONTENT_TEST_TEST_FIND_REQUEST_MANAGER_H_
+#define CONTENT_TEST_TEST_FIND_REQUEST_MANAGER_H_
+
+#include "base/gtest_prod_util.h"
+#include "content/browser/find_request_manager.h"
+#include "content/public/test/test_utils.h"
+
+namespace content {
+
+class WebContentsImpl;
+
+// TestFindRequestManager provides extra control and observation over
+// FindRequestManager for the purposes of testing, without altering its
+// behavior.
+class TestFindRequestManager : public FindRequestManager {
nasko 2016/04/15 19:26:50 Do we really need to subclass the FindRequestManag
paulmeyer 2016/04/18 19:11:22 Now using WebContentsDelegate instead.
+ public:
+ explicit TestFindRequestManager(WebContentsImpl* web_contents);
+ ~TestFindRequestManager() override;
+
+ // FindRequestManager overrides for testing.
+ void Find(int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options) override;
+
+ // Waits for the final reply to any pending find requests.
+ void WaitForFinalReply();
+
+ // The results of a find request.
+ struct FindResults {
+ int request_id;
+ int number_of_matches;
+ int active_match_ordinal;
+ };
+
+ // Returns the current find results.
+ FindResults GetFindResults();
+
+ private:
+ // FindRequestManager overrides for testing.
+ void NotifyFindReply(int request_id, bool final_update) const override;
+
+ // The ID of the last find request requested.
+ int last_request_id_;
+
+ // The ID of the last find request to finish (all replies received).
+ mutable int last_finished_request_id_;
+
+ // If waiting using |find_message_loop_runner_|, this is the ID of the find
+ // request being waited for.
+ int waiting_request_id_;
+
+ scoped_refptr<content::MessageLoopRunner> find_message_loop_runner_;
+};
+
+} // namespace content
+
+#endif // CONTENT_TEST_TEST_FIND_REQUEST_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698