Fix TracingTest failures (issue #2583)
This commit is contained in:
parent
bf51cd21b6
commit
667d190547
|
@ -78,24 +78,20 @@ class TracingTestHandler : public CefEndTracingCallback,
|
||||||
completion_event_ = CefWaitableEvent::CreateWaitableEvent(true, false);
|
completion_event_ = CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadTracingFile(const std::string& file_path) {
|
void ExecuteTest() {
|
||||||
EXPECT_FILE_THREAD();
|
// Run the test.
|
||||||
|
CefPostTask(TID_UI, base::Bind(&TracingTestHandler::BeginTracing, this));
|
||||||
|
|
||||||
EXPECT_TRUE(client::file_util::ReadFileToString(file_path, &trace_data_));
|
// Wait for the test to complete.
|
||||||
EXPECT_TRUE(CefDeleteFile(file_path, false));
|
completion_event_->Wait();
|
||||||
|
|
||||||
completion_event_->Signal();
|
// Verify the results.
|
||||||
|
EXPECT_TRUE(!trace_data_.empty());
|
||||||
|
EXPECT_TRUE(trace_type_ != NULL);
|
||||||
|
EXPECT_TRUE(strstr(trace_data_.c_str(), trace_type_) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CefEndTracingCallback method:
|
void BeginTracing() {
|
||||||
void OnEndTracingComplete(const CefString& tracing_file) override {
|
|
||||||
EXPECT_UI_THREAD();
|
|
||||||
|
|
||||||
CefPostTask(TID_FILE, base::Bind(&TracingTestHandler::ReadTracingFile, this,
|
|
||||||
tracing_file));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunTracing() {
|
|
||||||
EXPECT_UI_THREAD();
|
EXPECT_UI_THREAD();
|
||||||
|
|
||||||
// Results in a call to OnComplete.
|
// Results in a call to OnComplete.
|
||||||
|
@ -105,6 +101,14 @@ class TracingTestHandler : public CefEndTracingCallback,
|
||||||
void OnComplete() override {
|
void OnComplete() override {
|
||||||
EXPECT_UI_THREAD();
|
EXPECT_UI_THREAD();
|
||||||
|
|
||||||
|
// Add some delay to avoid timing-related test failures.
|
||||||
|
CefPostDelayedTask(TID_UI,
|
||||||
|
base::Bind(&TracingTestHandler::TestTracing, this), 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestTracing() {
|
||||||
|
EXPECT_UI_THREAD();
|
||||||
|
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case TT_TRACE_EVENT0: {
|
case TT_TRACE_EVENT0: {
|
||||||
TRACE_EVENT0(kTraceTestCategory, "TT_TRACE_EVENT0");
|
TRACE_EVENT0(kTraceTestCategory, "TT_TRACE_EVENT0");
|
||||||
|
@ -311,17 +315,20 @@ class TracingTestHandler : public CefEndTracingCallback,
|
||||||
CefEndTracing(CefString(), this);
|
CefEndTracing(CefString(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecuteTest() {
|
void OnEndTracingComplete(const CefString& tracing_file) override {
|
||||||
// Run the test.
|
EXPECT_UI_THREAD();
|
||||||
CefPostTask(TID_UI, base::Bind(&TracingTestHandler::RunTracing, this));
|
|
||||||
|
|
||||||
// Wait for the test to complete.
|
CefPostTask(TID_FILE, base::Bind(&TracingTestHandler::ReadTracingFile, this,
|
||||||
completion_event_->Wait();
|
tracing_file));
|
||||||
|
}
|
||||||
|
|
||||||
// Verify the results.
|
void ReadTracingFile(const std::string& file_path) {
|
||||||
EXPECT_TRUE(!trace_data_.empty());
|
EXPECT_FILE_THREAD();
|
||||||
EXPECT_TRUE(trace_type_ != NULL);
|
|
||||||
EXPECT_TRUE(strstr(trace_data_.c_str(), trace_type_) != NULL);
|
EXPECT_TRUE(client::file_util::ReadFileToString(file_path, &trace_data_));
|
||||||
|
EXPECT_TRUE(CefDeleteFile(file_path, false));
|
||||||
|
|
||||||
|
completion_event_->Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue