Roll src/third_party/WebKit 28cb7a5:eda0012 (svn 190243:190250)
[chromium-blink-merge.git] / ppapi / tests / test_trace_event.cc
blob58f23a65f834e79a1a21a982670adedfd53e8ca4
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/tests/test_trace_event.h"
7 #include "ppapi/cpp/module.h"
8 #include "ppapi/tests/testing_instance.h"
10 REGISTER_TEST_CASE(TraceEvent);
12 TestTraceEvent::TestTraceEvent(TestingInstance* instance)
13 : TestCase(instance),
14 interface_(NULL) {
17 bool TestTraceEvent::Init() {
18 interface_ = static_cast<const PPB_Trace_Event_Dev*>(
19 pp::Module::Get()->GetBrowserInterface(PPB_TRACE_EVENT_DEV_INTERFACE));
20 return !!interface_;
23 void TestTraceEvent::RunTests(const std::string& filter) {
24 RUN_TEST(Smoke, filter);
25 RUN_TEST(SmokeWithTimestamps, filter);
26 RUN_TEST(Clock, filter);
29 std::string TestTraceEvent::TestSmoke() {
30 // This test does not verify the log message actually reaches dev tracing, but
31 // it does test that the interface exists and that it can be called without
32 // crashing.
33 const void* cat_enabled = interface_->GetCategoryEnabled("bar");
34 interface_->AddTraceEvent('B', cat_enabled, "foo", 0, 0, NULL, NULL, NULL, 0);
35 interface_->AddTraceEvent('E', cat_enabled, "foo", 0, 0, NULL, NULL, NULL, 0);
36 PASS();
39 std::string TestTraceEvent::TestSmokeWithTimestamps() {
40 // This test does not verify the log message actually reaches dev tracing, but
41 // it does test that the interface exists and that it can be called without
42 // crashing.
43 const void* cat_enabled = interface_->GetCategoryEnabled("bar");
44 interface_->AddTraceEventWithThreadIdAndTimestamp(
45 'B', cat_enabled, "foo", 0, 0, 42, 0, NULL, NULL, NULL, 0);
46 interface_->AddTraceEventWithThreadIdAndTimestamp(
47 'B', cat_enabled, "foo", 0, 1, 43, 0, NULL, NULL, NULL, 0);
48 interface_->AddTraceEventWithThreadIdAndTimestamp(
49 'E', cat_enabled, "foo", 0, 0, 44, 0, NULL, NULL, NULL, 0);
50 interface_->AddTraceEventWithThreadIdAndTimestamp(
51 'E', cat_enabled, "foo", 0, 1, 45, 0, NULL, NULL, NULL, 0);
52 PASS();
55 std::string TestTraceEvent::TestClock() {
56 int64_t last = interface_->Now();
58 for(int i=0; i<5; ++i){
59 int64_t next = interface_->Now();
60 ASSERT_LE(last, next);
61 last = next;
64 PASS();