diff options
author | Andrew de los Reyes <adlr@chromium.org> | 2012-06-19 09:36:04 -0700 |
---|---|---|
committer | Andrew de los Reyes <adlr@chromium.org> | 2012-06-19 09:36:38 -0700 |
commit | 11e8aa4b11b7415f40681433102533e799f8dbfa (patch) | |
tree | e39765def2b8ac4efc451e37d49e0c3c1f6cfec2 /src/activity_replay.cc | |
parent | 499ed29547424de402d898327226d77ed9d125cd (diff) | |
download | libchrome-gestures-11e8aa4b11b7415f40681433102533e799f8dbfa.tar.gz |
Revert "replay_log: replay and verify the log in a strict way"
This reverts commit 84476fa5484985432c65e87c4a6473975f4f8080
Change-Id: Ie9e1e4eef7f6ebda43b5e5608614cd00fe85320e
Reviewed-on: https://gerrit.chromium.org/gerrit/25622
Commit-Ready: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Andrew de los Reyes <adlr@chromium.org>
Diffstat (limited to 'src/activity_replay.cc')
-rw-r--r-- | src/activity_replay.cc | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/src/activity_replay.cc b/src/activity_replay.cc index 92c16b3..19ea397 100644 --- a/src/activity_replay.cc +++ b/src/activity_replay.cc @@ -8,14 +8,12 @@ #include <base/json/json_reader.h> #include <base/json/json_writer.h> -#include <gtest/gtest.h> #include "gestures/include/logging.h" #include "gestures/include/prop_registry.h" #include "gestures/include/set.h" #include "gestures/include/util.h" -using std::endl; using std::set; using std::string; @@ -477,8 +475,8 @@ bool ActivityReplay::ParsePropChange(DictionaryValue* entry) { return true; } -// Replay the log and verify the output in a strict way. -void ActivityReplay::Replay(Interpreter* interpreter) { +bool ActivityReplay::Replay(Interpreter* interpreter) { + bool all_correct = true; bool pending_gs_flag = false; interpreter->SetHardwareProperties(hwprops_); stime_t last_timeout_req = -1.0; @@ -494,10 +492,10 @@ void ActivityReplay::Replay(Interpreter* interpreter) { Log("Input Finger ID: %d", hs.fingers[i].tracking_id); Gesture* next_gs = interpreter->SyncInterpret(&hs, &last_timeout_req); if (next_gs) { - EXPECT_FALSE(pending_gs_flag) << - "Unexpected gestures:" << endl << - " Actual gesture: " << last_gs.String() << endl << - "Expected gesture: NULL"; + if (pending_gs_flag) { + Err("Unexpected gesture: %s", last_gs.String().c_str()); + all_correct = false; + } Log("Output Gesture: %s", next_gs->String().c_str()); last_gs = *next_gs; pending_gs_flag = true; @@ -509,10 +507,10 @@ void ActivityReplay::Replay(Interpreter* interpreter) { Gesture* next_gs = interpreter->HandleTimer(entry->details.timestamp, &last_timeout_req); if (next_gs) { - EXPECT_FALSE(pending_gs_flag) << - "Unexpected gestures:" << endl << - " Actual gesture: " << last_gs.String() << endl << - "Expected gesture: NULL"; + if (pending_gs_flag) { + Err("Unexpected gesture: %s", last_gs.String().c_str()); + all_correct = false; + } Log("Output Gesture: %s", next_gs->String().c_str()); last_gs = *next_gs; pending_gs_flag = true; @@ -521,36 +519,32 @@ void ActivityReplay::Replay(Interpreter* interpreter) { } case ActivityLog::kCallbackRequest: if (!DoubleEq(last_timeout_req, entry->details.timestamp)) { - // Apply EXPECT_TRUE only when the fuzzy DoubleEq is not true. - EXPECT_TRUE(DoubleEq(last_timeout_req, entry->details.timestamp)) << - " Actual timeout request: " << last_timeout_req << endl << - "Expected timeout request: " << entry->details.timestamp << - " (entry idx " << i << ")"; + Err("Expected timeout request of %f, but log has %f (entry idx %zu)", + last_timeout_req, entry->details.timestamp, i); + all_correct = false; } break; case ActivityLog::kGesture: { - if (pending_gs_flag && last_gs == entry->details.gesture) { - Log("Gesture matched:\n Actual gesture: %s.\nExpected gesture: %s", - last_gs.String().c_str(), - entry->details.gesture.String().c_str()); + if (!pending_gs_flag || last_gs != entry->details.gesture) { + Err("Incorrect gesture:\n Expected: %s.\n Actual: %s", + entry->details.gesture.String().c_str(), + pending_gs_flag ? last_gs.String().c_str() : "(null)"); + all_correct = false; + } else { + Log("Gesture matched:\n Expected: %s.\n Actual: %s", + entry->details.gesture.String().c_str(), + last_gs.String().c_str()); } - EXPECT_TRUE(pending_gs_flag) << - "Incorrect gesture:" << endl << - " Actual gesture: NULL" << endl << - "Expected gesture: " << entry->details.gesture.String(); - if (pending_gs_flag) - EXPECT_TRUE(entry->details.gesture == last_gs) << - "Incorrect gesture:" << endl << - " Actual gesture: " << last_gs.String() << endl << - "Expected gesture: " << entry->details.gesture.String(); pending_gs_flag = false; break; } case ActivityLog::kPropChange: - EXPECT_TRUE(ReplayPropChange(entry->details.prop_change)); + if (!ReplayPropChange(entry->details.prop_change)) + all_correct = false; break; } } + return all_correct; } bool ActivityReplay::ReplayPropChange( |