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
)
17 bool TestTraceEvent::Init() {
18 interface_
= static_cast<const PPB_Trace_Event_Dev
*>(
19 pp::Module::Get()->GetBrowserInterface(PPB_TRACE_EVENT_DEV_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
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);
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
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);
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
);