Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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); | 104 base_msg.mutable_navigation(); |
|
Kevin M
2016/05/02 17:47:48
Why do this? |navigation| is already being created
shaktisahu
2016/05/16 20:19:02
Done.
| |
| 106 base_msg.set_target_tab_id(kTargetTab); | 105 base_msg.set_target_tab_id(kTargetTab); |
| 107 | 106 |
| 108 BlimpMessage navigation_state_msg = base_msg; | 107 BlimpMessage navigation_state_msg = base_msg; |
| 109 navigation_state_msg.mutable_navigation()->set_type( | 108 navigation_state_msg.mutable_navigation()->set_type( |
| 110 NavigationMessage::NAVIGATION_STATE_CHANGED); | 109 NavigationMessage::NAVIGATION_STATE_CHANGED); |
| 111 navigation_state_msg.mutable_navigation() | 110 navigation_state_msg.mutable_navigation() |
| 112 ->mutable_navigation_state_changed() | 111 ->mutable_navigation_state_changed() |
| 113 ->set_url("http://foo.com"); | 112 ->set_url("http://foo.com"); |
| 114 navigation_state_msg.mutable_navigation() | 113 navigation_state_msg.mutable_navigation() |
| 115 ->mutable_navigation_state_changed() | 114 ->mutable_navigation_state_changed() |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 145 go_forward_msg); | 144 go_forward_msg); |
| 146 | 145 |
| 147 BlimpMessage reload_msg = base_msg; | 146 BlimpMessage reload_msg = base_msg; |
| 148 reload_msg.mutable_navigation()->set_type(NavigationMessage::RELOAD); | 147 reload_msg.mutable_navigation()->set_type(NavigationMessage::RELOAD); |
| 149 VerifyLogOutput("type=NAVIGATION subtype=RELOAD target_tab_id=123", | 148 VerifyLogOutput("type=NAVIGATION subtype=RELOAD target_tab_id=123", |
| 150 reload_msg); | 149 reload_msg); |
| 151 } | 150 } |
| 152 | 151 |
| 153 TEST_F(LoggingTest, TabControl) { | 152 TEST_F(LoggingTest, TabControl) { |
| 154 BlimpMessage base_msg; | 153 BlimpMessage base_msg; |
| 155 base_msg.set_type(BlimpMessage::TAB_CONTROL); | 154 base_msg.mutable_tab_control(); |
| 156 base_msg.set_target_tab_id(kTargetTab); | 155 base_msg.set_target_tab_id(kTargetTab); |
| 157 | 156 |
| 158 BlimpMessage create_tab_msg = base_msg; | 157 BlimpMessage create_tab_msg = base_msg; |
| 159 create_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CREATE_TAB); | 158 create_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CREATE_TAB); |
| 160 VerifyLogOutput("type=TAB_CONTROL subtype=CREATE_TAB target_tab_id=123", | 159 VerifyLogOutput("type=TAB_CONTROL subtype=CREATE_TAB target_tab_id=123", |
| 161 create_tab_msg); | 160 create_tab_msg); |
| 162 | 161 |
| 163 BlimpMessage close_tab_msg = base_msg; | 162 BlimpMessage close_tab_msg = base_msg; |
| 164 close_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CLOSE_TAB); | 163 close_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CLOSE_TAB); |
| 165 VerifyLogOutput("type=TAB_CONTROL subtype=CLOSE_TAB target_tab_id=123", | 164 VerifyLogOutput("type=TAB_CONTROL subtype=CLOSE_TAB target_tab_id=123", |
| 166 close_tab_msg); | 165 close_tab_msg); |
| 167 | 166 |
| 168 BlimpMessage size_msg = base_msg; | 167 BlimpMessage size_msg = base_msg; |
| 169 size_msg.mutable_tab_control()->set_type(TabControlMessage::SIZE); | 168 size_msg.mutable_tab_control()->set_type(TabControlMessage::SIZE); |
| 170 size_msg.mutable_tab_control()->mutable_size()->set_width(640); | 169 size_msg.mutable_tab_control()->mutable_size()->set_width(640); |
| 171 size_msg.mutable_tab_control()->mutable_size()->set_height(480); | 170 size_msg.mutable_tab_control()->mutable_size()->set_height(480); |
| 172 size_msg.mutable_tab_control()->mutable_size()->set_device_pixel_ratio(2); | 171 size_msg.mutable_tab_control()->mutable_size()->set_device_pixel_ratio(2); |
| 173 VerifyLogOutput( | 172 VerifyLogOutput( |
| 174 "type=TAB_CONTROL subtype=SIZE size=640x480:2.00 target_tab_id=123", | 173 "type=TAB_CONTROL subtype=SIZE size=640x480:2.00 target_tab_id=123", |
| 175 size_msg); | 174 size_msg); |
| 176 } | 175 } |
| 177 | 176 |
| 178 TEST_F(LoggingTest, ProtocolControl) { | 177 TEST_F(LoggingTest, ProtocolControl) { |
| 179 BlimpMessage base_msg; | 178 BlimpMessage base_msg; |
| 180 base_msg.set_type(BlimpMessage::PROTOCOL_CONTROL); | 179 base_msg.mutable_protocol_control(); |
|
Kevin M
2016/05/02 17:47:48
Ditto
shaktisahu
2016/05/16 20:19:02
Done.
| |
| 181 | 180 |
| 182 BlimpMessage start_connection_msg = base_msg; | 181 BlimpMessage start_connection_msg = base_msg; |
| 183 start_connection_msg.mutable_protocol_control()->set_type( | 182 start_connection_msg.mutable_protocol_control()->set_type( |
| 184 ProtocolControlMessage::START_CONNECTION); | 183 ProtocolControlMessage::START_CONNECTION); |
| 185 start_connection_msg.mutable_protocol_control() | 184 start_connection_msg.mutable_protocol_control() |
| 186 ->mutable_start_connection() | 185 ->mutable_start_connection() |
| 187 ->set_client_token("token"); | 186 ->set_client_token("token"); |
| 188 start_connection_msg.mutable_protocol_control() | 187 start_connection_msg.mutable_protocol_control() |
| 189 ->mutable_start_connection() | 188 ->mutable_start_connection() |
| 190 ->set_protocol_version(2); | 189 ->set_protocol_version(2); |
| 191 VerifyLogOutput( | 190 VerifyLogOutput( |
| 192 "type=PROTOCOL_CONTROL subtype=START_CONNECTION " | 191 "type=PROTOCOL_CONTROL subtype=START_CONNECTION " |
| 193 "client_token=\"token\" protocol_version=2", | 192 "client_token=\"token\" protocol_version=2", |
| 194 start_connection_msg); | 193 start_connection_msg); |
| 195 | 194 |
| 196 BlimpMessage checkpoint_msg = base_msg; | 195 BlimpMessage checkpoint_msg = base_msg; |
| 197 start_connection_msg.mutable_protocol_control()->set_type( | 196 start_connection_msg.mutable_protocol_control()->set_type( |
| 198 ProtocolControlMessage::CHECKPOINT_ACK); | 197 ProtocolControlMessage::CHECKPOINT_ACK); |
| 199 start_connection_msg.mutable_protocol_control() | 198 start_connection_msg.mutable_protocol_control() |
| 200 ->mutable_checkpoint_ack() | 199 ->mutable_checkpoint_ack() |
| 201 ->set_checkpoint_id(123); | 200 ->set_checkpoint_id(123); |
| 202 VerifyLogOutput( | 201 VerifyLogOutput( |
| 203 "type=PROTOCOL_CONTROL subtype=CHECKPOINT_ACK " | 202 "type=PROTOCOL_CONTROL subtype=CHECKPOINT_ACK " |
| 204 "checkpoint_id=123", | 203 "checkpoint_id=123", |
| 205 start_connection_msg); | 204 start_connection_msg); |
| 206 } | 205 } |
| 207 | 206 |
| 208 TEST_F(LoggingTest, RenderWidget) { | 207 TEST_F(LoggingTest, RenderWidget) { |
| 209 BlimpMessage base_msg; | 208 BlimpMessage base_msg; |
| 210 base_msg.set_type(BlimpMessage::RENDER_WIDGET); | |
| 211 base_msg.mutable_render_widget()->set_render_widget_id(123); | 209 base_msg.mutable_render_widget()->set_render_widget_id(123); |
|
Kevin M
2016/05/02 17:47:48
Ditto
shaktisahu
2016/05/16 20:19:02
Not here I think.
| |
| 212 | 210 |
| 213 BlimpMessage initialize_msg = base_msg; | 211 BlimpMessage initialize_msg = base_msg; |
| 214 initialize_msg.mutable_render_widget()->set_type( | 212 initialize_msg.mutable_render_widget()->set_type( |
| 215 RenderWidgetMessage::INITIALIZE); | 213 RenderWidgetMessage::INITIALIZE); |
| 216 VerifyLogOutput("type=RENDER_WIDGET subtype=INITIALIZE render_widget_id=123", | 214 VerifyLogOutput("type=RENDER_WIDGET subtype=INITIALIZE render_widget_id=123", |
| 217 initialize_msg); | 215 initialize_msg); |
| 218 | 216 |
| 219 BlimpMessage created_msg = base_msg; | 217 BlimpMessage created_msg = base_msg; |
| 220 created_msg.mutable_render_widget()->set_type( | 218 created_msg.mutable_render_widget()->set_type( |
| 221 RenderWidgetMessage::CREATED); | 219 RenderWidgetMessage::CREATED); |
| 222 VerifyLogOutput("type=RENDER_WIDGET subtype=CREATED render_widget_id=123", | 220 VerifyLogOutput("type=RENDER_WIDGET subtype=CREATED render_widget_id=123", |
| 223 created_msg); | 221 created_msg); |
| 224 | 222 |
| 225 BlimpMessage deleted_msg = base_msg; | 223 BlimpMessage deleted_msg = base_msg; |
| 226 deleted_msg.mutable_render_widget()->set_type(RenderWidgetMessage::DELETED); | 224 deleted_msg.mutable_render_widget()->set_type(RenderWidgetMessage::DELETED); |
| 227 VerifyLogOutput("type=RENDER_WIDGET subtype=DELETED render_widget_id=123", | 225 VerifyLogOutput("type=RENDER_WIDGET subtype=DELETED render_widget_id=123", |
| 228 deleted_msg); | 226 deleted_msg); |
| 229 } | 227 } |
| 230 | 228 |
| 231 TEST_F(LoggingTest, Settings) { | 229 TEST_F(LoggingTest, Settings) { |
| 232 BlimpMessage message; | 230 BlimpMessage message; |
| 233 message.set_type(BlimpMessage::SETTINGS); | |
| 234 message.mutable_settings() | 231 message.mutable_settings() |
| 235 ->mutable_engine_settings() | 232 ->mutable_engine_settings() |
| 236 ->set_record_whole_document(true); | 233 ->set_record_whole_document(true); |
| 237 message.mutable_settings()->mutable_engine_settings()->set_client_os_info( | 234 message.mutable_settings()->mutable_engine_settings()->set_client_os_info( |
| 238 "wibble"); | 235 "wibble"); |
| 239 VerifyLogOutput( | 236 VerifyLogOutput( |
| 240 "type=SETTINGS subtype=ENGINE_SETTINGS record_whole_document=true " | 237 "type=SETTINGS subtype=ENGINE_SETTINGS record_whole_document=true " |
| 241 "client_os_info=\"wibble\"", | 238 "client_os_info=\"wibble\"", |
| 242 message); | 239 message); |
| 243 } | 240 } |
| 244 | 241 |
| 245 } // namespace | 242 } // namespace |
| 246 } // namespace blimp | 243 } // namespace blimp |
| OLD | NEW |