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

Side by Side Diff: blimp/common/logging_unittest.cc

Issue 1933053003: Used oneof in blimp_message.proto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 7 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
« no previous file with comments | « blimp/common/logging.cc ('k') | blimp/common/proto/blimp_message.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 #include <string> 6 #include <string>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "blimp/common/logging.h" 10 #include "blimp/common/logging.h"
(...skipping 25 matching lines...) Expand all
36 LoggingTest() {} 36 LoggingTest() {}
37 ~LoggingTest() override {} 37 ~LoggingTest() override {}
38 38
39 private: 39 private:
40 // Deletes the singleton on test termination. 40 // Deletes the singleton on test termination.
41 base::ShadowingAtExitManager at_exit_; 41 base::ShadowingAtExitManager at_exit_;
42 }; 42 };
43 43
44 TEST_F(LoggingTest, Compositor) { 44 TEST_F(LoggingTest, Compositor) {
45 BlimpMessage base_msg; 45 BlimpMessage base_msg;
46 base_msg.set_type(BlimpMessage::COMPOSITOR); 46 base_msg.mutable_compositor();
47 base_msg.set_target_tab_id(kTargetTab); 47 base_msg.set_target_tab_id(kTargetTab);
48 VerifyLogOutput("type=COMPOSITOR render_widget_id=0 target_tab_id=123", 48 VerifyLogOutput("type=COMPOSITOR render_widget_id=0 target_tab_id=123",
49 base_msg); 49 base_msg);
50 } 50 }
51 51
52 TEST_F(LoggingTest, Input) { 52 TEST_F(LoggingTest, Input) {
53 const char* fragment_format = 53 const char* fragment_format =
54 "type=INPUT render_widget_id=1 timestamp_seconds=2.000000 subtype=%s" 54 "type=INPUT render_widget_id=1 timestamp_seconds=2.000000 subtype=%s"
55 " target_tab_id=123"; 55 " target_tab_id=123";
56 56
57 BlimpMessage base_msg; 57 BlimpMessage base_msg;
58 base_msg.set_type(BlimpMessage::INPUT);
59 base_msg.set_target_tab_id(kTargetTab); 58 base_msg.set_target_tab_id(kTargetTab);
60 base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollBegin); 59 base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollBegin);
61 base_msg.mutable_input()->set_render_widget_id(1); 60 base_msg.mutable_input()->set_render_widget_id(1);
62 base_msg.mutable_input()->set_timestamp_seconds(2); 61 base_msg.mutable_input()->set_timestamp_seconds(2);
63 VerifyLogOutput(base::StringPrintf(fragment_format, "GestureScrollBegin"), 62 VerifyLogOutput(base::StringPrintf(fragment_format, "GestureScrollBegin"),
64 base_msg); 63 base_msg);
65 64
66 base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollEnd); 65 base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollEnd);
67 VerifyLogOutput(base::StringPrintf(fragment_format, "GestureScrollEnd"), 66 VerifyLogOutput(base::StringPrintf(fragment_format, "GestureScrollEnd"),
68 base_msg); 67 base_msg);
(...skipping 26 matching lines...) Expand all
95 ->mutable_gesture_fling_cancel() 94 ->mutable_gesture_fling_cancel()
96 ->set_prevent_boosting(true); 95 ->set_prevent_boosting(true);
97 VerifyLogOutput( 96 VerifyLogOutput(
98 "type=INPUT render_widget_id=1 timestamp_seconds=2.000000 " 97 "type=INPUT render_widget_id=1 timestamp_seconds=2.000000 "
99 "subtype=GestureFlingCancel prevent_boosting=true target_tab_id=123", 98 "subtype=GestureFlingCancel prevent_boosting=true target_tab_id=123",
100 base_msg); 99 base_msg);
101 } 100 }
102 101
103 TEST_F(LoggingTest, Navigation) { 102 TEST_F(LoggingTest, Navigation) {
104 BlimpMessage base_msg; 103 BlimpMessage base_msg;
105 base_msg.set_type(BlimpMessage::NAVIGATION);
106 base_msg.set_target_tab_id(kTargetTab); 104 base_msg.set_target_tab_id(kTargetTab);
107 105
108 BlimpMessage navigation_state_msg = base_msg; 106 BlimpMessage navigation_state_msg = base_msg;
109 navigation_state_msg.mutable_navigation()->set_type( 107 navigation_state_msg.mutable_navigation()->set_type(
110 NavigationMessage::NAVIGATION_STATE_CHANGED); 108 NavigationMessage::NAVIGATION_STATE_CHANGED);
111 navigation_state_msg.mutable_navigation() 109 navigation_state_msg.mutable_navigation()
112 ->mutable_navigation_state_changed() 110 ->mutable_navigation_state_changed()
113 ->set_url("http://foo.com"); 111 ->set_url("http://foo.com");
114 navigation_state_msg.mutable_navigation() 112 navigation_state_msg.mutable_navigation()
115 ->mutable_navigation_state_changed() 113 ->mutable_navigation_state_changed()
(...skipping 29 matching lines...) Expand all
145 go_forward_msg); 143 go_forward_msg);
146 144
147 BlimpMessage reload_msg = base_msg; 145 BlimpMessage reload_msg = base_msg;
148 reload_msg.mutable_navigation()->set_type(NavigationMessage::RELOAD); 146 reload_msg.mutable_navigation()->set_type(NavigationMessage::RELOAD);
149 VerifyLogOutput("type=NAVIGATION subtype=RELOAD target_tab_id=123", 147 VerifyLogOutput("type=NAVIGATION subtype=RELOAD target_tab_id=123",
150 reload_msg); 148 reload_msg);
151 } 149 }
152 150
153 TEST_F(LoggingTest, TabControl) { 151 TEST_F(LoggingTest, TabControl) {
154 BlimpMessage base_msg; 152 BlimpMessage base_msg;
155 base_msg.set_type(BlimpMessage::TAB_CONTROL);
156 base_msg.set_target_tab_id(kTargetTab); 153 base_msg.set_target_tab_id(kTargetTab);
157 154
158 BlimpMessage create_tab_msg = base_msg; 155 BlimpMessage create_tab_msg = base_msg;
159 create_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CREATE_TAB); 156 create_tab_msg.mutable_tab_control()->mutable_create_tab();
160 VerifyLogOutput("type=TAB_CONTROL subtype=CREATE_TAB target_tab_id=123", 157 VerifyLogOutput("type=TAB_CONTROL subtype=CREATE_TAB target_tab_id=123",
161 create_tab_msg); 158 create_tab_msg);
162 159
163 BlimpMessage close_tab_msg = base_msg; 160 BlimpMessage close_tab_msg = base_msg;
164 close_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CLOSE_TAB); 161 close_tab_msg.mutable_tab_control()->mutable_close_tab();
165 VerifyLogOutput("type=TAB_CONTROL subtype=CLOSE_TAB target_tab_id=123", 162 VerifyLogOutput("type=TAB_CONTROL subtype=CLOSE_TAB target_tab_id=123",
166 close_tab_msg); 163 close_tab_msg);
167 164
168 BlimpMessage size_msg = base_msg; 165 BlimpMessage size_msg = base_msg;
169 size_msg.mutable_tab_control()->set_type(TabControlMessage::SIZE); 166 size_msg.mutable_tab_control()->mutable_size();
170 size_msg.mutable_tab_control()->mutable_size()->set_width(640); 167 size_msg.mutable_tab_control()->mutable_size()->set_width(640);
171 size_msg.mutable_tab_control()->mutable_size()->set_height(480); 168 size_msg.mutable_tab_control()->mutable_size()->set_height(480);
172 size_msg.mutable_tab_control()->mutable_size()->set_device_pixel_ratio(2); 169 size_msg.mutable_tab_control()->mutable_size()->set_device_pixel_ratio(2);
173 VerifyLogOutput( 170 VerifyLogOutput(
174 "type=TAB_CONTROL subtype=SIZE size=640x480:2.00 target_tab_id=123", 171 "type=TAB_CONTROL subtype=SIZE size=640x480:2.00 target_tab_id=123",
175 size_msg); 172 size_msg);
176 } 173 }
177 174
178 TEST_F(LoggingTest, ProtocolControl) { 175 TEST_F(LoggingTest, ProtocolControl) {
179 BlimpMessage base_msg; 176 BlimpMessage base_msg;
180 base_msg.set_type(BlimpMessage::PROTOCOL_CONTROL);
181 177
182 BlimpMessage start_connection_msg = base_msg; 178 BlimpMessage start_connection_msg = base_msg;
183 start_connection_msg.mutable_protocol_control()->set_type( 179 start_connection_msg.mutable_protocol_control()->mutable_start_connection();
184 ProtocolControlMessage::START_CONNECTION);
185 start_connection_msg.mutable_protocol_control() 180 start_connection_msg.mutable_protocol_control()
186 ->mutable_start_connection() 181 ->mutable_start_connection()
187 ->set_client_token("token"); 182 ->set_client_token("token");
188 start_connection_msg.mutable_protocol_control() 183 start_connection_msg.mutable_protocol_control()
189 ->mutable_start_connection() 184 ->mutable_start_connection()
190 ->set_protocol_version(2); 185 ->set_protocol_version(2);
191 VerifyLogOutput( 186 VerifyLogOutput(
192 "type=PROTOCOL_CONTROL subtype=START_CONNECTION " 187 "type=PROTOCOL_CONTROL subtype=START_CONNECTION "
193 "client_token=\"token\" protocol_version=2", 188 "client_token=\"token\" protocol_version=2",
194 start_connection_msg); 189 start_connection_msg);
195 190
196 BlimpMessage checkpoint_msg = base_msg; 191 start_connection_msg.mutable_protocol_control()->mutable_checkpoint_ack();
197 start_connection_msg.mutable_protocol_control()->set_type(
198 ProtocolControlMessage::CHECKPOINT_ACK);
199 start_connection_msg.mutable_protocol_control() 192 start_connection_msg.mutable_protocol_control()
200 ->mutable_checkpoint_ack() 193 ->mutable_checkpoint_ack()
201 ->set_checkpoint_id(123); 194 ->set_checkpoint_id(123);
202 VerifyLogOutput( 195 VerifyLogOutput(
203 "type=PROTOCOL_CONTROL subtype=CHECKPOINT_ACK " 196 "type=PROTOCOL_CONTROL subtype=CHECKPOINT_ACK "
204 "checkpoint_id=123", 197 "checkpoint_id=123",
205 start_connection_msg); 198 start_connection_msg);
206 } 199 }
207 200
208 TEST_F(LoggingTest, RenderWidget) { 201 TEST_F(LoggingTest, RenderWidget) {
209 BlimpMessage base_msg; 202 BlimpMessage base_msg;
210 base_msg.set_type(BlimpMessage::RENDER_WIDGET);
211 base_msg.mutable_render_widget()->set_render_widget_id(123); 203 base_msg.mutable_render_widget()->set_render_widget_id(123);
212 204
213 BlimpMessage initialize_msg = base_msg; 205 BlimpMessage initialize_msg = base_msg;
214 initialize_msg.mutable_render_widget()->set_type( 206 initialize_msg.mutable_render_widget()->set_type(
215 RenderWidgetMessage::INITIALIZE); 207 RenderWidgetMessage::INITIALIZE);
216 VerifyLogOutput("type=RENDER_WIDGET subtype=INITIALIZE render_widget_id=123", 208 VerifyLogOutput("type=RENDER_WIDGET subtype=INITIALIZE render_widget_id=123",
217 initialize_msg); 209 initialize_msg);
218 210
219 BlimpMessage created_msg = base_msg; 211 BlimpMessage created_msg = base_msg;
220 created_msg.mutable_render_widget()->set_type( 212 created_msg.mutable_render_widget()->set_type(
221 RenderWidgetMessage::CREATED); 213 RenderWidgetMessage::CREATED);
222 VerifyLogOutput("type=RENDER_WIDGET subtype=CREATED render_widget_id=123", 214 VerifyLogOutput("type=RENDER_WIDGET subtype=CREATED render_widget_id=123",
223 created_msg); 215 created_msg);
224 216
225 BlimpMessage deleted_msg = base_msg; 217 BlimpMessage deleted_msg = base_msg;
226 deleted_msg.mutable_render_widget()->set_type(RenderWidgetMessage::DELETED); 218 deleted_msg.mutable_render_widget()->set_type(RenderWidgetMessage::DELETED);
227 VerifyLogOutput("type=RENDER_WIDGET subtype=DELETED render_widget_id=123", 219 VerifyLogOutput("type=RENDER_WIDGET subtype=DELETED render_widget_id=123",
228 deleted_msg); 220 deleted_msg);
229 } 221 }
230 222
231 TEST_F(LoggingTest, Settings) { 223 TEST_F(LoggingTest, Settings) {
232 BlimpMessage message; 224 BlimpMessage message;
233 message.set_type(BlimpMessage::SETTINGS);
234 message.mutable_settings() 225 message.mutable_settings()
235 ->mutable_engine_settings() 226 ->mutable_engine_settings()
236 ->set_record_whole_document(true); 227 ->set_record_whole_document(true);
237 message.mutable_settings()->mutable_engine_settings()->set_client_os_info( 228 message.mutable_settings()->mutable_engine_settings()->set_client_os_info(
238 "wibble"); 229 "wibble");
239 VerifyLogOutput( 230 VerifyLogOutput(
240 "type=SETTINGS subtype=ENGINE_SETTINGS record_whole_document=true " 231 "type=SETTINGS subtype=ENGINE_SETTINGS record_whole_document=true "
241 "client_os_info=\"wibble\"", 232 "client_os_info=\"wibble\"",
242 message); 233 message);
243 } 234 }
244 235
245 } // namespace 236 } // namespace
246 } // namespace blimp 237 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/common/logging.cc ('k') | blimp/common/proto/blimp_message.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698