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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/test/test_find_request_manager.h"
6
7 #include "content/browser/web_contents/web_contents_impl.h"
8
9 namespace content {
10
11 TestFindRequestManager::TestFindRequestManager(WebContentsImpl* web_contents)
12 : FindRequestManager(web_contents),
13 last_request_id_(kInvalidId),
14 last_finished_request_id_(kInvalidId),
15 waiting_request_id_(kInvalidId) {}
16
17 TestFindRequestManager::~TestFindRequestManager() {}
18
19 void TestFindRequestManager::Find(int request_id,
20 const base::string16& search_text,
21 const blink::WebFindOptions& options) {
22 last_request_id_ = request_id;
23 FindRequestManager::Find(request_id, search_text, options);
24 }
25
26 void TestFindRequestManager::WaitForFinalReply() {
27 if (last_finished_request_id_ == last_request_id_)
28 return;
29
30 waiting_request_id_ = last_request_id_;
31 find_message_loop_runner_ = new content::MessageLoopRunner;
32 find_message_loop_runner_->Run();
33 }
34
35 TestFindRequestManager::FindResults TestFindRequestManager::GetFindResults() {
36 FindResults results;
37 results.request_id = last_finished_request_id_;
38 results.number_of_matches = number_of_matches_;
39 results.active_match_ordinal = active_match_ordinal_;
40 return results;
41 }
42
43 void TestFindRequestManager::NotifyFindReply(int request_id,
44 bool final_update) const {
45 if (final_update)
46 last_finished_request_id_ = request_id;
47
48 // If we are waiting for a final reply and this is it, stop waiting.
49 if (find_message_loop_runner_.get() &&
50 last_finished_request_id_ >= waiting_request_id_) {
51 find_message_loop_runner_->Quit();
52 }
53
54 FindRequestManager::NotifyFindReply(request_id, final_update);
55 }
56
57 } // namespace content
OLDNEW
« 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