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

Unified Diff: apps/benchmark/event_unittest.cc

Issue 1381933002: Fix the benchmark app to handle real-world events (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/benchmark/event.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/benchmark/event_unittest.cc
diff --git a/apps/benchmark/event_unittest.cc b/apps/benchmark/event_unittest.cc
index 53441d316d460ac79ea2bcb768f69901a995387a..a20b2e33ea424ecc028d48189b9ba3096d9bb003 100644
--- a/apps/benchmark/event_unittest.cc
+++ b/apps/benchmark/event_unittest.cc
@@ -145,6 +145,25 @@ TEST(GetEventsTest, DurationEventsTwoThreads) {
EXPECT_EQ(base::TimeDelta::FromInternalValue(2), events[1].duration);
}
+TEST(GetEventsTest, DurationEventsTidIsString) {
+ std::vector<std::string> event_specs(2);
+ event_specs[0] =
+ "{\"tid\":\"1\",\"ts\":1,\"ph\":\"B\",\"cat\":\"cc\","
+ "\"name\":\"t1 event\"}";
+ event_specs[1] = "{\"tid\":1,\"ts\":3,\"ph\":\"E\"}";
+
+ std::string trace_json = "[" + JoinString(event_specs, ',') + "]";
+ std::vector<Event> events;
+ ASSERT_TRUE(GetEvents(trace_json, &events));
+ ASSERT_EQ(1u, events.size());
+
+ EXPECT_EQ(EventType::COMPLETE, events[0].type);
+ EXPECT_EQ("t1 event", events[0].name);
+ EXPECT_EQ("cc", events[0].categories);
+ EXPECT_EQ(base::TimeTicks::FromInternalValue(1), events[0].timestamp);
+ EXPECT_EQ(base::TimeDelta::FromInternalValue(2), events[0].duration);
+}
+
TEST(GetEventsTest, AsyncEvents) {
std::vector<std::string> event_specs(4);
event_specs[0] =
@@ -178,6 +197,27 @@ TEST(GetEventsTest, AsyncEvents) {
EXPECT_EQ(base::TimeDelta::FromInternalValue(2), events[1].duration);
}
+TEST(GetEventsTest, AsyncEventIdIsString) {
+ std::vector<std::string> event_specs(2);
+ event_specs[0] =
+ "{\"tid\":1001,\"id\":\"a\",\"ts\":1,\"ph\":\"S\",\"cat\":\"cc\","
+ "\"name\":\"t1 event\"}";
+ event_specs[1] =
+ "{\"tid\":1003,\"id\":\"a\",\"ts\":3,\"ph\":\"F\",\"cat\":\"cc\","
+ "\"name\":\"t1 event\"}";
+
+ std::string trace_json = "[" + JoinString(event_specs, ',') + "]";
+ std::vector<Event> events;
+ ASSERT_TRUE(GetEvents(trace_json, &events));
+ ASSERT_EQ(1u, events.size());
+
+ EXPECT_EQ(EventType::COMPLETE, events[0].type);
+ EXPECT_EQ("t1 event", events[0].name);
+ EXPECT_EQ("cc", events[0].categories);
+ EXPECT_EQ(base::TimeTicks::FromInternalValue(1), events[0].timestamp);
+ EXPECT_EQ(base::TimeDelta::FromInternalValue(2), events[0].duration);
+}
+
} // namespace
} // namespace benchmark
« no previous file with comments | « apps/benchmark/event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698