Chromium Code Reviews| Index: blimp/common/logging_unittest.cc |
| diff --git a/blimp/common/logging_unittest.cc b/blimp/common/logging_unittest.cc |
| index 238aa59391dd2e4bb20cf4ca03a3fc3dd4138946..cde3328638c9716152e39d7891894767e503a8d4 100644 |
| --- a/blimp/common/logging_unittest.cc |
| +++ b/blimp/common/logging_unittest.cc |
| @@ -20,23 +20,27 @@ namespace { |
| const int kTargetTab = 123; |
| +// Verifies that the logged form of |msg| matches |expected|, modulo prefix |
| +// and suffix. |
| +void VerifyLogOutput(const std::string& expected_fragment, |
| + const BlimpMessage& msg) { |
| + std::string expected = "<BlimpMessage " + expected_fragment + " byte_size=" + |
| + std::to_string(msg.ByteSize()) + ">"; |
| + std::stringstream outstream; |
| + outstream << msg; |
| + EXPECT_EQ(expected, outstream.str()); |
| +} |
| + |
| +std::string GetExpectedFragmentOfInputMessage(const std::string& type) { |
|
Kevin M
2016/04/05 17:59:13
We don't need to create a helper function like thi
haibinlu1
2016/04/05 18:19:57
Done.
|
| + return "type=INPUT render_widget_id=1 timestamp_seconds=2.000000 subtype=" + |
| + type + " target_tab_id=123"; |
| +} |
| + |
| class LoggingTest : public testing::Test { |
| public: |
| LoggingTest() {} |
| ~LoggingTest() override {} |
| - protected: |
| - // Verifies that the logged form of |msg| matches |expected|, modulo prefix |
| - // and suffix. |
| - void VerifyLogOutput(const std::string& expected_fragment, |
| - const BlimpMessage& msg) { |
| - std::string expected = "<BlimpMessage " + expected_fragment + |
| - " byte_size=" + std::to_string(msg.ByteSize()) + ">"; |
| - std::stringstream outstream; |
| - outstream << msg; |
| - EXPECT_EQ(expected, outstream.str()); |
| - } |
| - |
| private: |
| // Deletes the singleton on test termination. |
| base::ShadowingAtExitManager at_exit_; |
| @@ -54,7 +58,47 @@ TEST_F(LoggingTest, Input) { |
| BlimpMessage base_msg; |
| base_msg.set_type(BlimpMessage::INPUT); |
| base_msg.set_target_tab_id(kTargetTab); |
| - VerifyLogOutput("type=INPUT render_widget_id=0 target_tab_id=123", base_msg); |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollBegin); |
| + base_msg.mutable_input()->set_render_widget_id(1); |
| + base_msg.mutable_input()->set_timestamp_seconds(2); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GestureScrollBegin"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollEnd); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GestureScrollEnd"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GestureScrollUpdate); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GestureScrollUpdate"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GestureFlingStart); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GestureFlingStart"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GestureTap); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GestureTap"), base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GesturePinchBegin); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GesturePinchBegin"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GesturePinchEnd); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GesturePinchEnd"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GesturePinchUpdate); |
| + VerifyLogOutput(GetExpectedFragmentOfInputMessage("GesturePinchUpdate"), |
| + base_msg); |
| + |
| + base_msg.mutable_input()->set_type(InputMessage::Type_GestureFlingCancel); |
| + base_msg.mutable_input() |
| + ->mutable_gesture_fling_cancel() |
| + ->set_prevent_boosting(true); |
| + VerifyLogOutput( |
| + "type=INPUT render_widget_id=1 timestamp_seconds=2.000000 " |
| + "subtype=GestureFlingCancel prevent_boosting=true target_tab_id=123", |
| + base_msg); |
| } |
| TEST_F(LoggingTest, Navigation) { |