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

Side by Side Diff: chrome/test/automation/autocomplete_edit_proxy.h

Issue 7104029: Automation: fix chrome/browser dependency on chrome/test headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_AUTOMATION_AUTOCOMPLETE_EDIT_PROXY_H_
6 #define CHROME_TEST_AUTOMATION_AUTOCOMPLETE_EDIT_PROXY_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/string_number_conversions.h"
13 #include "chrome/browser/autocomplete/autocomplete.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/test/automation/automation_handle_tracker.h"
16 #include "googleurl/src/gurl.h"
17 #include "ipc/ipc_message.h"
18 #include "ipc/ipc_message_utils.h"
19
20 // The purpose of this class is to act as a serializable version of
21 // AutocompleteMatch. The reason for this class is because we don't want to
22 // serialize all elements of AutocompleteMatch and we want some data from the
23 // autocomplete provider without the hassle of serializing it.
24 struct AutocompleteMatchData {
25 public:
26 AutocompleteMatchData()
27 : relevance(0),
28 deletable(false),
29 inline_autocomplete_offset(0),
30 is_history_what_you_typed_match(false),
31 starred(false) {
32 }
33
34 explicit AutocompleteMatchData(const AutocompleteMatch& match)
35 : provider_name(match.provider->name()),
36 relevance(match.relevance),
37 deletable(match.deletable),
38 fill_into_edit(match.fill_into_edit),
39 inline_autocomplete_offset(match.inline_autocomplete_offset),
40 destination_url(match.destination_url),
41 contents(match.contents),
42 description(match.description),
43 is_history_what_you_typed_match(match.is_history_what_you_typed_match),
44 type(AutocompleteMatch::TypeToString(match.type)),
45 starred(match.starred) {
46 }
47
48 std::string provider_name;
49 int relevance;
50 bool deletable;
51 string16 fill_into_edit;
52 size_t inline_autocomplete_offset;
53 GURL destination_url;
54 string16 contents;
55 string16 description;
56 bool is_history_what_you_typed_match;
57 std::string type;
58 bool starred;
59 };
60 typedef std::vector<AutocompleteMatchData> Matches;
61
62 namespace IPC {
63
64 template <>
65 struct ParamTraits<AutocompleteMatchData> {
66 typedef AutocompleteMatchData param_type;
67 static void Write(Message* m, const param_type& p) {
68 m->WriteString(p.provider_name);
69 m->WriteInt(p.relevance);
70 m->WriteBool(p.deletable);
71 m->WriteString16(p.fill_into_edit);
72 m->WriteSize(p.inline_autocomplete_offset);
73 m->WriteString(p.destination_url.possibly_invalid_spec());
74 m->WriteString16(p.contents);
75 m->WriteString16(p.description);
76 m->WriteBool(p.is_history_what_you_typed_match);
77 m->WriteString(p.type);
78 m->WriteBool(p.starred);
79 }
80
81 static bool Read(const Message* m, void** iter, param_type* r) {
82 std::string destination_url;
83 if (!m->ReadString(iter, &r->provider_name) ||
84 !m->ReadInt(iter, &r->relevance) ||
85 !m->ReadBool(iter, &r->deletable) ||
86 !m->ReadString16(iter, &r->fill_into_edit) ||
87 !m->ReadSize(iter, &r->inline_autocomplete_offset) ||
88 !m->ReadString(iter, &destination_url) ||
89 !m->ReadString16(iter, &r->contents) ||
90 !m->ReadString16(iter, &r->description) ||
91 !m->ReadBool(iter, &r->is_history_what_you_typed_match) ||
92 !m->ReadString(iter, &r->type) ||
93 !m->ReadBool(iter, &r->starred))
94 return false;
95 r->destination_url = GURL(destination_url);
96 return true;
97 }
98
99 static void Log(const param_type& p, std::string* l) {
100 l->append("[");
101 l->append(p.provider_name);
102 l->append(" ");
103 l->append(base::IntToString(p.relevance));
104 l->append(" ");
105 l->append(p.deletable ? "true" : "false");
106 l->append(" ");
107 LogParam(p.fill_into_edit, l);
108 l->append(" ");
109 l->append(base::IntToString(p.inline_autocomplete_offset));
110 l->append(" ");
111 l->append(p.destination_url.spec());
112 l->append(" ");
113 LogParam(p.contents, l);
114 l->append(" ");
115 LogParam(p.description, l);
116 l->append(" ");
117 l->append(p.is_history_what_you_typed_match ? "true" : "false");
118 l->append(" ");
119 l->append(p.type);
120 l->append(" ");
121 l->append(p.starred ? "true" : "false");
122 l->append("]");
123 }
124 };
125 } // namespace IPC
126
127 class AutocompleteEditProxy : public AutomationResourceProxy {
128 public:
129 AutocompleteEditProxy(AutomationMessageSender* sender,
130 AutomationHandleTracker* tracker,
131 int handle)
132 : AutomationResourceProxy(tracker, sender, handle) {}
133 virtual ~AutocompleteEditProxy() {}
134
135 // All these functions return true if the autocomplete edit is valid and
136 // there are no IPC errors.
137
138 // Gets the text visible in the omnibox.
139 bool GetText(string16* text) const;
140
141 // Sets the text visible in the omnibox.
142 bool SetText(const string16& text);
143
144 // Determines if a query to an autocomplete provider is still in progress.
145 // NOTE: No autocomplete queries will be made if the omnibox doesn't have
146 // focus. This can be achieved by sending a IDC_FOCUS_LOCATION accelerator
147 // to the browser.
148 bool IsQueryInProgress(bool* query_in_progress) const;
149
150 // Gets a list of autocomplete matches that have been gathered so far.
151 bool GetAutocompleteMatches(Matches* matches) const;
152
153 // Waits for the autocomplete edit to receive focus.
154 bool WaitForFocus() const;
155
156 // Waits for all queries to autocomplete providers to complete.
157 // |wait_timeout_ms| gives the number of milliseconds to wait for the query
158 // to finish. Returns false if IPC call failed or if the function times out.
159 bool WaitForQuery(int wait_timeout_ms) const;
160
161 private:
162 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditProxy);
163 };
164
165 #endif // CHROME_TEST_AUTOMATION_AUTOCOMPLETE_EDIT_PROXY_H_
OLDNEW
« no previous file with comments | « chrome/common/automation_messages_internal.h ('k') | chrome/test/automation/autocomplete_edit_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698