OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
dmichael (off chromium)
2013/06/24 17:43:42
ditto, 2013
grosse
2013/06/24 23:16:46
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ppapi/tests/test_dev_trace_event.h" | |
6 | |
7 #include "ppapi/cpp/module.h" | |
8 #include "ppapi/tests/testing_instance.h" | |
9 | |
10 REGISTER_TEST_CASE(DevTraceEvent); | |
11 | |
12 TestDevTraceEvent::TestDevTraceEvent(TestingInstance* instance) | |
13 : TestCase(instance), | |
14 interface_(NULL) { | |
15 } | |
16 | |
17 bool TestDevTraceEvent::Init() { | |
18 interface_ = static_cast<const PPB_Trace_Event_Dev*>( | |
19 pp::Module::Get()->GetBrowserInterface(PPB_TRACE_EVENT_DEV_INTERFACE)); | |
20 return !!interface_; | |
21 } | |
22 | |
23 void TestDevTraceEvent::RunTests(const std::string& filter) { | |
24 RUN_TEST(Smoke, filter); | |
25 RUN_TEST(SmokeWithTimestamps, filter); | |
26 RUN_TEST(Clock, filter); | |
27 } | |
28 | |
29 std::string TestDevTraceEvent::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(); | |
37 } | |
38 | |
39 std::string TestDevTraceEvent::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('B', cat_enabled, "foo", 0, | |
bradn
2013/06/22 16:09:25
Nit, maybe wrap these from the paren down, so they
grosse
2013/06/24 23:16:46
Done.
| |
45 0, 42, 0, NULL, NULL, NULL, | |
46 0); | |
47 interface_->AddTraceEventWithThreadIdAndTimestamp('B', cat_enabled, "foo", 0, | |
48 1, 43, 0, NULL, NULL, NULL, | |
49 0); | |
50 interface_->AddTraceEventWithThreadIdAndTimestamp('E', cat_enabled, "foo", 0, | |
51 0, 44, 0, NULL, NULL, NULL, | |
52 0); | |
53 interface_->AddTraceEventWithThreadIdAndTimestamp('E', cat_enabled, "foo", 0, | |
54 1, 45, 0, NULL, NULL, NULL, | |
55 0); | |
56 PASS(); | |
57 } | |
58 | |
59 std::string TestDevTraceEvent::TestClock() { | |
60 int64_t last = interface_->Now(); | |
61 | |
62 for(int i=0; i<5; ++i){ | |
63 int64_t next = interface_->Now(); | |
64 ASSERT_LE(last, next); | |
65 last = next; | |
66 } | |
67 | |
68 PASS(); | |
69 } | |
OLD | NEW |