summaryrefslogtreecommitdiff
path: root/src/activity_replay_unittest.cc
blob: ef75491cd8669be060f2832d203dda738cbc1fce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2012 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <set>
#include <string>
#include <vector>

#include <gtest/gtest.h>

#include "include/activity_replay.h"
#include "include/command_line.h"
#include "include/file_util.h"
#include "include/finger_metrics.h"
#include "include/gestures.h"
#include "include/logging_filter_interpreter.h"
#include "include/string_util.h"

using std::string;

namespace gestures {

class ActivityReplayTest : public ::testing::Test {};

// This test reads a log file and replays it. This test should be enabled for a
// hands-on debugging session.

TEST(ActivityReplayTest, DISABLED_SimpleTest) {
  CommandLine* cl = CommandLine::ForCurrentProcess();
  GestureInterpreter* c_interpreter = NewGestureInterpreter();
  c_interpreter->Initialize();

  Interpreter* interpreter = c_interpreter->interpreter();
  PropRegistry* prop_reg = c_interpreter->prop_reg();
  {
    MetricsProperties mprops(prop_reg);

    string log_contents;
    ASSERT_TRUE(ReadFileToString(cl->GetSwitchValueASCII("in").c_str(),
                                 &log_contents));

    ActivityReplay replay(prop_reg);
    std::vector<string> honor_props;
    if (cl->GetSwitchValueASCII("only_honor")[0])
      SplitString(cl->GetSwitchValueASCII("only_honor"),
                        ',', &honor_props);
    std::set<string> honor_props_set(honor_props.begin(), honor_props.end());
    replay.Parse(log_contents, honor_props_set);
    replay.Replay(interpreter, &mprops);

    // Dump the new log
    const string kOutSwitchName = "outfile";
    if (cl->HasSwitch(kOutSwitchName))
      static_cast<LoggingFilterInterpreter*>(interpreter)->Dump(
          cl->GetSwitchValueASCII(kOutSwitchName).c_str());
  }

  DeleteGestureInterpreter(c_interpreter);
}

}  // namespace gestures