2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
2012-10-18 00:45:49 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2014-07-15 20:10:40 +02:00
|
|
|
#include "include/base/cef_bind.h"
|
2016-11-15 18:56:02 +01:00
|
|
|
#include "include/cef_file_util.h"
|
2012-10-18 00:45:49 +02:00
|
|
|
#include "include/cef_task.h"
|
|
|
|
#include "include/cef_trace.h"
|
2016-11-15 22:18:41 +01:00
|
|
|
#include "include/cef_waitable_event.h"
|
2014-07-15 20:10:40 +02:00
|
|
|
#include "include/wrapper/cef_closure_task.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/gtest/include/gtest/gtest.h"
|
2016-11-15 18:56:02 +01:00
|
|
|
#include "tests/unittests/file_util.h"
|
2014-07-15 00:18:51 +02:00
|
|
|
#include "tests/unittests/test_handler.h"
|
2012-10-18 00:45:49 +02:00
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
// Use the CEF version of the TRACE_* macros instead of the Chromium version.
|
|
|
|
#undef USING_CHROMIUM_INCLUDES
|
|
|
|
#include "include/base/cef_trace_event.h"
|
|
|
|
|
2012-10-18 00:45:49 +02:00
|
|
|
enum TracingTestType {
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT0,
|
|
|
|
TT_TRACE_EVENT1,
|
|
|
|
TT_TRACE_EVENT2,
|
|
|
|
TT_TRACE_EVENT_INSTANT0,
|
|
|
|
TT_TRACE_EVENT_INSTANT1,
|
|
|
|
TT_TRACE_EVENT_INSTANT2,
|
|
|
|
TT_TRACE_EVENT_COPY_INSTANT0,
|
|
|
|
TT_TRACE_EVENT_COPY_INSTANT1,
|
|
|
|
TT_TRACE_EVENT_COPY_INSTANT2,
|
|
|
|
TT_TRACE_EVENT_BEGIN0,
|
|
|
|
TT_TRACE_EVENT_BEGIN1,
|
|
|
|
TT_TRACE_EVENT_BEGIN2,
|
|
|
|
TT_TRACE_EVENT_COPY_BEGIN0,
|
|
|
|
TT_TRACE_EVENT_COPY_BEGIN1,
|
|
|
|
TT_TRACE_EVENT_COPY_BEGIN2,
|
|
|
|
TT_TRACE_EVENT_END0,
|
|
|
|
TT_TRACE_EVENT_END1,
|
|
|
|
TT_TRACE_EVENT_END2,
|
|
|
|
TT_TRACE_EVENT_COPY_END0,
|
|
|
|
TT_TRACE_EVENT_COPY_END1,
|
|
|
|
TT_TRACE_EVENT_COPY_END2,
|
|
|
|
TT_TRACE_COUNTER1,
|
|
|
|
TT_TRACE_COPY_COUNTER1,
|
|
|
|
TT_TRACE_COUNTER2,
|
|
|
|
TT_TRACE_COPY_COUNTER2,
|
|
|
|
TT_TRACE_COUNTER_ID1,
|
|
|
|
TT_TRACE_COPY_COUNTER_ID1,
|
|
|
|
TT_TRACE_COUNTER_ID2,
|
|
|
|
TT_TRACE_COPY_COUNTER_ID2,
|
|
|
|
TT_TRACE_EVENT_ASYNC_BEGIN0,
|
|
|
|
TT_TRACE_EVENT_ASYNC_BEGIN1,
|
|
|
|
TT_TRACE_EVENT_ASYNC_BEGIN2,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_BEGIN0,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_BEGIN1,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_BEGIN2,
|
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_INTO0,
|
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_INTO1,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1,
|
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_PAST0,
|
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_PAST1,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1,
|
|
|
|
TT_TRACE_EVENT_ASYNC_END0,
|
|
|
|
TT_TRACE_EVENT_ASYNC_END1,
|
|
|
|
TT_TRACE_EVENT_ASYNC_END2,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_END0,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_END1,
|
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_END2
|
2012-10-18 00:45:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const char kTraceTestCategory[] = "test_category";
|
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
class TracingTestHandler : public CefEndTracingCallback,
|
|
|
|
public CefCompletionCallback {
|
2012-10-18 00:45:49 +02:00
|
|
|
public:
|
|
|
|
TracingTestHandler(TracingTestType type, const char* trace_type)
|
2016-11-15 22:18:41 +01:00
|
|
|
: trace_type_(trace_type),
|
2012-10-18 00:45:49 +02:00
|
|
|
type_(type) {
|
2016-11-15 22:18:41 +01:00
|
|
|
completion_event_ = CefWaitableEvent::CreateWaitableEvent(true, false);
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
2016-11-15 18:56:02 +01:00
|
|
|
void ReadTracingFile(const std::string& file_path) {
|
2014-02-05 21:35:45 +01:00
|
|
|
EXPECT_FILE_THREAD();
|
2013-12-17 23:04:35 +01:00
|
|
|
|
2016-11-15 18:56:02 +01:00
|
|
|
EXPECT_TRUE(file_util::ReadFileToString(file_path, &trace_data_));
|
|
|
|
EXPECT_TRUE(CefDeleteFile(file_path, false));
|
2012-10-18 00:45:49 +02:00
|
|
|
|
2016-11-15 22:18:41 +01:00
|
|
|
completion_event_->Signal();
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
2013-12-17 23:04:35 +01:00
|
|
|
// CefEndTracingCallback method:
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnEndTracingComplete(const CefString& tracing_file) override {
|
2014-02-05 21:35:45 +01:00
|
|
|
EXPECT_UI_THREAD();
|
2013-12-17 23:04:35 +01:00
|
|
|
|
|
|
|
CefPostTask(TID_FILE,
|
2016-11-15 18:56:02 +01:00
|
|
|
base::Bind(&TracingTestHandler::ReadTracingFile, this, tracing_file));
|
2013-12-17 23:04:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RunTracing() {
|
2014-02-05 21:35:45 +01:00
|
|
|
EXPECT_UI_THREAD();
|
2013-12-17 23:04:35 +01:00
|
|
|
|
2014-02-05 21:35:45 +01:00
|
|
|
// Results in a call to OnComplete.
|
|
|
|
CefBeginTracing(kTraceTestCategory, this);
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnComplete() override {
|
2014-02-05 21:35:45 +01:00
|
|
|
EXPECT_UI_THREAD();
|
2012-10-18 00:45:49 +02:00
|
|
|
|
|
|
|
switch (type_) {
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT0: {
|
|
|
|
TRACE_EVENT0(kTraceTestCategory, "TT_TRACE_EVENT0");
|
2013-05-31 15:25:38 +02:00
|
|
|
} break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT1: {
|
|
|
|
TRACE_EVENT1(kTraceTestCategory, "TT_TRACE_EVENT1", "arg1", 1);
|
2013-05-31 15:25:38 +02:00
|
|
|
} break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT2: {
|
|
|
|
TRACE_EVENT2(kTraceTestCategory, "TT_TRACE_EVENT2", "arg1", 1,
|
|
|
|
"arg2", 2);
|
2013-05-31 15:25:38 +02:00
|
|
|
} break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_INSTANT0:
|
|
|
|
TRACE_EVENT_INSTANT0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_INSTANT0");
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_INSTANT1:
|
|
|
|
TRACE_EVENT_INSTANT1(kTraceTestCategory, "TT_TRACE_EVENT_INSTANT1",
|
|
|
|
"arg1", 1);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_INSTANT2:
|
|
|
|
TRACE_EVENT_INSTANT2(kTraceTestCategory, "TT_TRACE_EVENT_INSTANT2",
|
|
|
|
"arg1", 1, "arg2", 2);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_INSTANT0:
|
|
|
|
TRACE_EVENT_COPY_INSTANT0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_INSTANT0");
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_INSTANT1:
|
|
|
|
TRACE_EVENT_COPY_INSTANT1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_INSTANT1",
|
|
|
|
"arg1", 1);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_INSTANT2:
|
|
|
|
TRACE_EVENT_COPY_INSTANT2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_INSTANT2",
|
|
|
|
"arg1", 1, "arg2", 2);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_BEGIN0:
|
|
|
|
TRACE_EVENT_BEGIN0(kTraceTestCategory, "TT_TRACE_EVENT_BEGIN0");
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_BEGIN1:
|
|
|
|
TRACE_EVENT_BEGIN1(kTraceTestCategory, "TT_TRACE_EVENT_BEGIN1",
|
|
|
|
"arg1", 1);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_BEGIN2:
|
|
|
|
TRACE_EVENT_BEGIN2(kTraceTestCategory, "TT_TRACE_EVENT_BEGIN2",
|
|
|
|
"arg1", 1, "arg2", 2);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_BEGIN0:
|
|
|
|
TRACE_EVENT_COPY_BEGIN0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_BEGIN0");
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_BEGIN1:
|
|
|
|
TRACE_EVENT_COPY_BEGIN1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_BEGIN1",
|
|
|
|
"arg1", 1);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_BEGIN2:
|
|
|
|
TRACE_EVENT_COPY_BEGIN2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_BEGIN2",
|
|
|
|
"arg1", 1, "arg2", 2);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_END0:
|
|
|
|
TRACE_EVENT_END0(kTraceTestCategory, "TT_TRACE_EVENT_END0");
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_END1:
|
|
|
|
TRACE_EVENT_END1(kTraceTestCategory, "TT_TRACE_EVENT_END1",
|
2012-10-18 00:45:49 +02:00
|
|
|
"arg1", 1);
|
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_END2:
|
|
|
|
TRACE_EVENT_END2(kTraceTestCategory, "TT_TRACE_EVENT_END2",
|
|
|
|
"arg1", 1, "arg2", 2);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_END0:
|
|
|
|
TRACE_EVENT_COPY_END0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_END0");
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_END1:
|
|
|
|
TRACE_EVENT_COPY_END1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_END1", "arg1", 1);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_END2:
|
|
|
|
TRACE_EVENT_COPY_END2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_END2", "arg1", 1, "arg2", 2);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COUNTER1:
|
|
|
|
TRACE_COUNTER1(kTraceTestCategory, "TT_TRACE_COUNTER1", 5);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COPY_COUNTER1:
|
|
|
|
TRACE_COPY_COUNTER1(kTraceTestCategory, "TT_TRACE_COPY_COUNTER1", 5);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COUNTER2:
|
|
|
|
TRACE_COUNTER2(kTraceTestCategory, "TT_TRACE_COUNTER2", "val1", 5,
|
|
|
|
"val2", 10);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COPY_COUNTER2:
|
|
|
|
TRACE_COPY_COUNTER2(kTraceTestCategory, "TT_TRACE_COPY_COUNTER2",
|
|
|
|
"val1", 5, "val2", 10);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COUNTER_ID1:
|
|
|
|
TRACE_COUNTER_ID1(kTraceTestCategory, "TT_TRACE_COUNTER_ID1", 100, 5);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COPY_COUNTER_ID1:
|
|
|
|
TRACE_COPY_COUNTER_ID1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_COPY_COUNTER_ID1", 100, 5);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_COUNTER_ID2:
|
|
|
|
TRACE_COUNTER_ID2(kTraceTestCategory, "TT_TRACE_COUNTER_ID2", 100,
|
|
|
|
"val1", 5, "val2", 10);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_COPY_COUNTER_ID2:
|
|
|
|
TRACE_COPY_COUNTER_ID2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_COPY_COUNTER_ID2", 100,
|
|
|
|
"val1", 5, "val2", 10);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_BEGIN0:
|
|
|
|
TRACE_EVENT_ASYNC_BEGIN0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_ASYNC_BEGIN0", 100);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_BEGIN1:
|
|
|
|
TRACE_EVENT_ASYNC_BEGIN1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_ASYNC_BEGIN1", 100, "arg1", 1);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_BEGIN2:
|
|
|
|
TRACE_EVENT_ASYNC_BEGIN2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_ASYNC_BEGIN2",
|
|
|
|
100, "arg1", 1, "arg2", 2);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_BEGIN0:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_BEGIN0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_ASYNC_BEGIN0",
|
|
|
|
100);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_BEGIN1:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_BEGIN1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_ASYNC_BEGIN1",
|
|
|
|
100, "arg1", 1);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_BEGIN2:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_BEGIN2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_ASYNC_BEGIN2",
|
|
|
|
100, "arg1", 1, "arg2", 2);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_STEP_INTO0:
|
|
|
|
TRACE_EVENT_ASYNC_STEP_INTO0(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_INTO0", 100, 1000);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_STEP_INTO1:
|
|
|
|
TRACE_EVENT_ASYNC_STEP_INTO1(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_INTO1", 100, 1000,
|
2013-10-29 18:53:18 +01:00
|
|
|
"arg1", 1);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_STEP_INTO0(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0", 100,
|
2013-10-29 18:53:18 +01:00
|
|
|
1000);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_STEP_INTO1(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1", 100,
|
2013-10-29 18:53:18 +01:00
|
|
|
1000, "arg1", 1);
|
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_ASYNC_STEP_PAST0:
|
|
|
|
TRACE_EVENT_ASYNC_STEP_PAST0(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_PAST0", 100, 1000);
|
2013-10-29 18:53:18 +01:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_ASYNC_STEP_PAST1:
|
|
|
|
TRACE_EVENT_ASYNC_STEP_PAST1(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_PAST1", 100, 1000,
|
2013-10-29 18:53:18 +01:00
|
|
|
"arg1", 1);
|
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_STEP_PAST0(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0", 100,
|
2013-10-29 18:53:18 +01:00
|
|
|
1000);
|
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_STEP_PAST1(
|
|
|
|
kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1", 100,
|
2013-10-29 18:53:18 +01:00
|
|
|
1000, "arg1", 1);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
2014-07-11 22:10:05 +02:00
|
|
|
case TT_TRACE_EVENT_ASYNC_END0:
|
|
|
|
TRACE_EVENT_ASYNC_END0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_ASYNC_END0", 100);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_END1:
|
|
|
|
TRACE_EVENT_ASYNC_END1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_ASYNC_END1", 100,
|
|
|
|
"arg1", 1);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_ASYNC_END2:
|
|
|
|
TRACE_EVENT_ASYNC_END2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_ASYNC_END2", 100,
|
|
|
|
"arg1", 1, "arg2", 2);
|
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_END0:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_END0(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_ASYNC_END0",
|
|
|
|
100);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_END1:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_END1(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_ASYNC_END1",
|
|
|
|
100, "arg1", 1);
|
|
|
|
break;
|
|
|
|
case TT_TRACE_EVENT_COPY_ASYNC_END2:
|
|
|
|
TRACE_EVENT_COPY_ASYNC_END2(kTraceTestCategory,
|
|
|
|
"TT_TRACE_EVENT_COPY_ASYNC_END2",
|
|
|
|
100, "arg1", 1, "arg2", 2);
|
2012-10-18 00:45:49 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-12-17 23:04:35 +01:00
|
|
|
// Results in a call to OnEndTracingComplete.
|
2014-02-05 21:35:45 +01:00
|
|
|
CefEndTracing(CefString(), this);
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ExecuteTest() {
|
|
|
|
// Run the test.
|
2014-07-15 20:10:40 +02:00
|
|
|
CefPostTask(TID_UI, base::Bind(&TracingTestHandler::RunTracing, this));
|
2012-10-18 00:45:49 +02:00
|
|
|
|
|
|
|
// Wait for the test to complete.
|
2016-11-15 22:18:41 +01:00
|
|
|
completion_event_->Wait();
|
2013-12-17 23:04:35 +01:00
|
|
|
|
|
|
|
// Verify the results.
|
|
|
|
EXPECT_TRUE(!trace_data_.empty());
|
|
|
|
EXPECT_TRUE(trace_type_ != NULL);
|
|
|
|
EXPECT_TRUE(strstr(trace_data_.c_str(), trace_type_) != NULL);
|
2012-10-18 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-11-12 20:25:15 +01:00
|
|
|
~TracingTestHandler() override {}
|
2012-10-18 00:45:49 +02:00
|
|
|
|
|
|
|
// Handle used to notify when the test is complete.
|
2016-11-15 22:18:41 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> completion_event_;
|
2012-10-18 00:45:49 +02:00
|
|
|
|
|
|
|
const char* trace_type_;
|
|
|
|
TracingTestType type_;
|
|
|
|
std::string trace_data_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(TracingTestHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Helper for defining tracing tests.
|
|
|
|
#define TRACING_TEST(name, test_type) \
|
|
|
|
TEST(TracingTest, name) { \
|
|
|
|
CefRefPtr<TracingTestHandler> handler = \
|
|
|
|
new TracingTestHandler(test_type, #test_type); \
|
|
|
|
handler->ExecuteTest(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Define the tests.
|
2014-07-11 22:10:05 +02:00
|
|
|
TRACING_TEST(TraceEvent0, TT_TRACE_EVENT0);
|
|
|
|
TRACING_TEST(TraceEvent1, TT_TRACE_EVENT1);
|
|
|
|
TRACING_TEST(TraceEvent2, TT_TRACE_EVENT2);
|
|
|
|
TRACING_TEST(TraceEventInstant0, TT_TRACE_EVENT_INSTANT0);
|
|
|
|
TRACING_TEST(TraceEventInstant1, TT_TRACE_EVENT_INSTANT1);
|
|
|
|
TRACING_TEST(TraceEventInstant2, TT_TRACE_EVENT_INSTANT2);
|
|
|
|
TRACING_TEST(TraceEventCopyInstant0, TT_TRACE_EVENT_COPY_INSTANT0);
|
|
|
|
TRACING_TEST(TraceEventCopyInstant1, TT_TRACE_EVENT_COPY_INSTANT1);
|
|
|
|
TRACING_TEST(TraceEventCopyInstant2, TT_TRACE_EVENT_COPY_INSTANT2);
|
|
|
|
TRACING_TEST(TraceEventBegin0, TT_TRACE_EVENT_BEGIN0);
|
|
|
|
TRACING_TEST(TraceEventBegin1, TT_TRACE_EVENT_BEGIN1);
|
|
|
|
TRACING_TEST(TraceEventBegin2, TT_TRACE_EVENT_BEGIN2);
|
|
|
|
TRACING_TEST(TraceEventCopyBegin0, TT_TRACE_EVENT_COPY_BEGIN0);
|
|
|
|
TRACING_TEST(TraceEventCopyBegin1, TT_TRACE_EVENT_COPY_BEGIN1);
|
|
|
|
TRACING_TEST(TraceEventCopyBegin2, TT_TRACE_EVENT_COPY_BEGIN2);
|
|
|
|
TRACING_TEST(TraceEventEnd0, TT_TRACE_EVENT_END0);
|
|
|
|
TRACING_TEST(TraceEventEnd1, TT_TRACE_EVENT_END1);
|
|
|
|
TRACING_TEST(TraceEventEnd2, TT_TRACE_EVENT_END2);
|
|
|
|
TRACING_TEST(TraceEventCopyEnd0, TT_TRACE_EVENT_COPY_END0);
|
|
|
|
TRACING_TEST(TraceEventCopyEnd1, TT_TRACE_EVENT_COPY_END1);
|
|
|
|
TRACING_TEST(TraceEventCopyEnd2, TT_TRACE_EVENT_COPY_END1);
|
|
|
|
TRACING_TEST(TraceCounter1, TT_TRACE_COUNTER1);
|
|
|
|
TRACING_TEST(TraceCopyCounter1, TT_TRACE_COPY_COUNTER1);
|
|
|
|
TRACING_TEST(TraceCounter2, TT_TRACE_COUNTER2);
|
|
|
|
TRACING_TEST(TraceCopyCounter2, TT_TRACE_COPY_COUNTER2);
|
|
|
|
TRACING_TEST(TraceCounterId1, TT_TRACE_COUNTER_ID1);
|
|
|
|
TRACING_TEST(TraceCopyCounterId1, TT_TRACE_COPY_COUNTER_ID1);
|
|
|
|
TRACING_TEST(TraceCounterId2, TT_TRACE_COUNTER_ID2);
|
|
|
|
TRACING_TEST(TraceCopyCounterId2, TT_TRACE_COPY_COUNTER_ID1);
|
|
|
|
TRACING_TEST(TraceEventAsyncBegin0, TT_TRACE_EVENT_ASYNC_BEGIN0);
|
|
|
|
TRACING_TEST(TraceEventAsyncBegin1, TT_TRACE_EVENT_ASYNC_BEGIN1);
|
|
|
|
TRACING_TEST(TraceEventAsyncBegin2, TT_TRACE_EVENT_ASYNC_BEGIN2);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncBegin0,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_BEGIN0);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncBegin1,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_BEGIN1);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncBegin2,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_BEGIN2);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventAsyncStepInto0,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_INTO0);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventAsyncStepInto1,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_INTO1);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncStepInto0,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncStepInto1,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventAsyncStepPast0,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_PAST0);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventAsyncStepPast1,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_ASYNC_STEP_PAST1);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncStepPast0,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0);
|
2013-10-29 18:53:18 +01:00
|
|
|
TRACING_TEST(TraceEventCopyAsyncStepPast1,
|
2014-07-11 22:10:05 +02:00
|
|
|
TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1);
|
|
|
|
TRACING_TEST(TraceEventAsyncEnd0, TT_TRACE_EVENT_ASYNC_END0);
|
|
|
|
TRACING_TEST(TraceEventAsyncEnd1, TT_TRACE_EVENT_ASYNC_END1);
|
|
|
|
TRACING_TEST(TraceEventAsyncEnd2, TT_TRACE_EVENT_ASYNC_END2);
|
|
|
|
TRACING_TEST(TraceEventCopyAsyncEnd0, TT_TRACE_EVENT_COPY_ASYNC_END0);
|
2013-03-15 20:57:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
TEST(TracingTest, NowFromSystemTraceTime) {
|
|
|
|
int64 val = CefNowFromSystemTraceTime();
|
|
|
|
EXPECT_NE(val, 0);
|
|
|
|
}
|