2016-11-12 00:22:53 +01:00
|
|
|
// Copyright 2016 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
#include "include/base/cef_callback.h"
|
2021-06-19 21:54:45 +02:00
|
|
|
#include "include/base/cef_callback_helpers.h"
|
2016-11-12 00:22:53 +01:00
|
|
|
#include "include/cef_task.h"
|
|
|
|
#include "include/cef_thread.h"
|
|
|
|
#include "include/wrapper/cef_closure_task.h"
|
2016-11-18 18:31:21 +01:00
|
|
|
#include "tests/ceftests/test_handler.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/gtest/include/gtest/gtest.h"
|
|
|
|
#include "tests/shared/browser/client_app_browser.h"
|
|
|
|
#include "tests/shared/renderer/client_app_renderer.h"
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
using client::ClientAppBrowser;
|
|
|
|
using client::ClientAppRenderer;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Base class for creating and testing threads.
|
|
|
|
class ThreadTest : public base::RefCountedThreadSafe<ThreadTest> {
|
|
|
|
public:
|
2024-01-20 18:00:09 +01:00
|
|
|
ThreadTest() = default;
|
|
|
|
virtual ~ThreadTest() = default;
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
// Create the test thread. Should only be called one time.
|
|
|
|
void CreateTestThread() {
|
|
|
|
EXPECT_TRUE(!thread_.get());
|
|
|
|
|
|
|
|
owner_task_runner_ = CefTaskRunner::GetForCurrentThread();
|
|
|
|
EXPECT_TRUE(owner_task_runner_.get());
|
|
|
|
EXPECT_TRUE(owner_task_runner_->BelongsToCurrentThread());
|
|
|
|
|
|
|
|
thread_ = CefThread::CreateThread("test_thread");
|
|
|
|
EXPECT_TRUE(thread_.get());
|
|
|
|
EXPECT_TRUE(thread_->IsRunning());
|
|
|
|
|
|
|
|
thread_id_ = thread_->GetPlatformThreadId();
|
|
|
|
EXPECT_NE(thread_id_, kInvalidPlatformThreadId);
|
|
|
|
|
|
|
|
thread_task_runner_ = thread_->GetTaskRunner();
|
|
|
|
EXPECT_TRUE(thread_task_runner_.get());
|
|
|
|
|
|
|
|
AssertOwnerThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy the test thread. Should only be called one time.
|
|
|
|
void DestroyTestThread() {
|
|
|
|
EXPECT_TRUE(thread_.get());
|
|
|
|
AssertOwnerThread();
|
|
|
|
|
|
|
|
EXPECT_TRUE(thread_->IsRunning());
|
|
|
|
thread_->Stop();
|
|
|
|
EXPECT_FALSE(thread_->IsRunning());
|
|
|
|
|
|
|
|
AssertOwnerThread();
|
|
|
|
|
|
|
|
thread_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Execute |test_task| on the test thread. After execution |callback| will be
|
|
|
|
// posted to |callback_task_runner|.
|
|
|
|
void PostOnTestThreadAndCallback(
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceClosure test_task,
|
2016-11-12 00:22:53 +01:00
|
|
|
CefRefPtr<CefTaskRunner> callback_task_runner,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceClosure callback) {
|
2016-11-12 00:22:53 +01:00
|
|
|
EXPECT_TRUE(thread_.get());
|
2021-06-19 21:54:45 +02:00
|
|
|
thread_task_runner_->PostTask(CefCreateClosureTask(base::BindOnce(
|
|
|
|
&ThreadTest::ExecuteOnTestThread, this, std::move(test_task),
|
|
|
|
callback_task_runner, std::move(callback))));
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefTaskRunner> owner_task_runner() const {
|
|
|
|
return owner_task_runner_;
|
|
|
|
}
|
|
|
|
CefRefPtr<CefTaskRunner> thread_task_runner() const {
|
|
|
|
return thread_task_runner_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assert that we're running on the owner thread.
|
|
|
|
void AssertOwnerThread() {
|
|
|
|
EXPECT_TRUE(owner_task_runner_->BelongsToCurrentThread());
|
|
|
|
EXPECT_FALSE(thread_task_runner_->BelongsToCurrentThread());
|
|
|
|
EXPECT_TRUE(thread_task_runner_->IsSame(thread_->GetTaskRunner()));
|
|
|
|
EXPECT_EQ(thread_id_, thread_->GetPlatformThreadId());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assert that we're running on the test thread.
|
|
|
|
void AssertTestThread() {
|
|
|
|
EXPECT_FALSE(owner_task_runner_->BelongsToCurrentThread());
|
|
|
|
EXPECT_TRUE(thread_task_runner_->BelongsToCurrentThread());
|
|
|
|
EXPECT_TRUE(thread_task_runner_->IsSame(thread_->GetTaskRunner()));
|
|
|
|
EXPECT_EQ(thread_id_, thread_->GetPlatformThreadId());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Helper for PostOnTestThreadAndCallback().
|
2021-06-19 21:54:45 +02:00
|
|
|
void ExecuteOnTestThread(base::OnceClosure test_task,
|
2016-11-12 00:22:53 +01:00
|
|
|
CefRefPtr<CefTaskRunner> callback_task_runner,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceClosure callback) {
|
2016-11-12 00:22:53 +01:00
|
|
|
AssertTestThread();
|
|
|
|
|
2021-06-19 21:54:45 +02:00
|
|
|
std::move(test_task).Run();
|
2016-11-12 00:22:53 +01:00
|
|
|
|
2021-06-19 21:54:45 +02:00
|
|
|
callback_task_runner->PostTask(CefCreateClosureTask(std::move(callback)));
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefTaskRunner> owner_task_runner_;
|
|
|
|
|
|
|
|
CefRefPtr<CefThread> thread_;
|
|
|
|
cef_platform_thread_id_t thread_id_;
|
|
|
|
CefRefPtr<CefTaskRunner> thread_task_runner_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ThreadTest);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// Test thread creation and destruction without any task execution.
|
|
|
|
TEST(ThreadTest, Create) {
|
|
|
|
scoped_refptr<ThreadTest> thread_test = new ThreadTest();
|
|
|
|
thread_test->CreateTestThread();
|
|
|
|
thread_test->DestroyTestThread();
|
|
|
|
thread_test = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Simple implementation of ThreadTest that creates a thread, executes tasks
|
|
|
|
// on the thread, then destroys the thread after all tasks have completed.
|
|
|
|
class SimpleThreadTest : public ThreadTest {
|
|
|
|
public:
|
|
|
|
SimpleThreadTest(size_t expected_task_count,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceClosure task_callback,
|
|
|
|
base::OnceClosure done_callback)
|
2017-05-17 11:29:28 +02:00
|
|
|
: expected_task_count_(expected_task_count),
|
2021-06-19 21:54:45 +02:00
|
|
|
task_callback_(std::move(task_callback)),
|
2024-01-20 18:00:09 +01:00
|
|
|
done_callback_(std::move(done_callback)) {}
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
void RunTest() {
|
|
|
|
// Create the test thread.
|
|
|
|
CreateTestThread();
|
|
|
|
|
|
|
|
for (size_t i = 0U; i < expected_task_count_; ++i) {
|
|
|
|
// Execute Task() on the test thread and then call Done() on this thread.
|
2021-06-19 21:54:45 +02:00
|
|
|
PostOnTestThreadAndCallback(
|
|
|
|
base::BindOnce(&SimpleThreadTest::Task, this), owner_task_runner(),
|
|
|
|
base::BindOnce(&SimpleThreadTest::Done, this));
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyTest() {
|
|
|
|
EXPECT_EQ(expected_task_count_, got_task_count_);
|
|
|
|
EXPECT_EQ(expected_task_count_, got_done_count_);
|
|
|
|
|
|
|
|
// Destroy the test thread.
|
|
|
|
DestroyTestThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Task() {
|
|
|
|
AssertTestThread();
|
|
|
|
got_task_count_++;
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!task_callback_.is_null()) {
|
2021-06-19 21:54:45 +02:00
|
|
|
std::move(task_callback_).Run();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Done() {
|
|
|
|
AssertOwnerThread();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (++got_done_count_ == expected_task_count_ &&
|
|
|
|
!done_callback_.is_null()) {
|
2021-06-19 21:54:45 +02:00
|
|
|
std::move(done_callback_).Run();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const size_t expected_task_count_;
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceClosure task_callback_;
|
|
|
|
base::OnceClosure done_callback_;
|
2016-11-12 00:22:53 +01:00
|
|
|
|
2024-01-20 18:00:09 +01:00
|
|
|
size_t got_task_count_ = 0U;
|
|
|
|
size_t got_done_count_ = 0U;
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SimpleThreadTest);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Test creation/execution of threads in the browser process.
|
|
|
|
|
2023-04-29 00:17:03 +02:00
|
|
|
const char kBrowserThreadTestHtml[] = "https://test.com/browserthread.html";
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
// Browser side.
|
|
|
|
class BrowserThreadTestHandler : public TestHandler {
|
|
|
|
public:
|
|
|
|
explicit BrowserThreadTestHandler(CefThreadId owner_thread_id)
|
2017-05-17 11:29:28 +02:00
|
|
|
: owner_thread_id_(owner_thread_id) {}
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
void RunTest() override {
|
|
|
|
AddResource(kBrowserThreadTestHtml, "<html><body>Test</body></html>",
|
|
|
|
"text/html");
|
|
|
|
|
|
|
|
CreateBrowser(kBrowserThreadTestHtml);
|
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunThreadTestOnOwnerThread() {
|
|
|
|
if (!CefCurrentlyOn(owner_thread_id_)) {
|
|
|
|
// Run the test on the desired owner thread.
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostTask(
|
|
|
|
owner_thread_id_,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::BindOnce(&BrowserThreadTestHandler::RunThreadTestOnOwnerThread,
|
|
|
|
this));
|
2016-11-12 00:22:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_FALSE(thread_test_.get());
|
|
|
|
thread_test_ = new SimpleThreadTest(
|
2021-06-19 21:54:45 +02:00
|
|
|
3, base::DoNothing(),
|
|
|
|
base::BindOnce(&BrowserThreadTestHandler::DoneOnOwnerThread, this));
|
2016-11-12 00:22:53 +01:00
|
|
|
thread_test_->RunTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoneOnOwnerThread() {
|
|
|
|
// Let the call stack unwind before destroying |thread_test_|.
|
2021-06-19 21:54:45 +02:00
|
|
|
CefPostTask(owner_thread_id_,
|
|
|
|
base::BindOnce(
|
|
|
|
&BrowserThreadTestHandler::DestroyTestOnOwnerThread, this));
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyTestOnOwnerThread() {
|
|
|
|
EXPECT_TRUE(CefCurrentlyOn(owner_thread_id_));
|
|
|
|
|
|
|
|
EXPECT_TRUE(thread_test_.get());
|
|
|
|
if (thread_test_) {
|
|
|
|
thread_test_->DestroyTest();
|
|
|
|
thread_test_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
got_test_done_.yes();
|
|
|
|
|
|
|
|
// Call DestroyTest() on the UI thread.
|
|
|
|
CefPostTask(TID_UI,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::BindOnce(&BrowserThreadTestHandler::DestroyTest, this));
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
bool isLoading,
|
|
|
|
bool canGoBack,
|
|
|
|
bool canGoForward) override {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!isLoading) {
|
2016-11-12 00:22:53 +01:00
|
|
|
RunThreadTestOnOwnerThread();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void DestroyTest() override {
|
|
|
|
EXPECT_FALSE(thread_test_.get());
|
|
|
|
EXPECT_TRUE(got_test_done_);
|
|
|
|
|
|
|
|
TestHandler::DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
const CefThreadId owner_thread_id_;
|
|
|
|
|
|
|
|
scoped_refptr<SimpleThreadTest> thread_test_;
|
|
|
|
TrackCallback got_test_done_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(BrowserThreadTestHandler);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BrowserThreadTestHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// Test creation of new threads from the browser UI thread.
|
|
|
|
TEST(ThreadTest, CreateFromBrowserUIThread) {
|
|
|
|
CefRefPtr<BrowserThreadTestHandler> handler =
|
|
|
|
new BrowserThreadTestHandler(TID_UI);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test creation of new threads from the browser IO thread.
|
|
|
|
TEST(ThreadTest, CreateFromBrowserIOThread) {
|
|
|
|
CefRefPtr<BrowserThreadTestHandler> handler =
|
|
|
|
new BrowserThreadTestHandler(TID_IO);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test creation of new threads from the browser FILE thread.
|
|
|
|
TEST(ThreadTest, CreateFromBrowserFILEThread) {
|
2020-09-25 03:40:47 +02:00
|
|
|
// Use a FILE thread that will run tasks relatively quickly.
|
2016-11-12 00:22:53 +01:00
|
|
|
CefRefPtr<BrowserThreadTestHandler> handler =
|
2020-09-25 03:40:47 +02:00
|
|
|
new BrowserThreadTestHandler(TID_FILE_USER_VISIBLE);
|
2016-11-12 00:22:53 +01:00
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Test creation/execution of threads in the render process.
|
|
|
|
|
2023-04-29 00:17:03 +02:00
|
|
|
const char kRenderThreadTestHtml[] = "https://test.com/renderthread.html";
|
2016-11-12 00:22:53 +01:00
|
|
|
const char kRenderThreadTestMsg[] = "ThreadTest.RenderThreadTest";
|
|
|
|
|
|
|
|
// Browser side.
|
|
|
|
class RenderThreadTestHandler : public TestHandler {
|
|
|
|
public:
|
2024-01-20 18:00:09 +01:00
|
|
|
RenderThreadTestHandler() = default;
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
void RunTest() override {
|
|
|
|
AddResource(kRenderThreadTestHtml, "<html><body>Test</body></html>",
|
|
|
|
"text/html");
|
|
|
|
|
|
|
|
CreateBrowser(kRenderThreadTestHtml);
|
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
bool isLoading,
|
|
|
|
bool canGoBack,
|
|
|
|
bool canGoForward) override {
|
|
|
|
if (!isLoading) {
|
|
|
|
// Return the test in the render process.
|
|
|
|
CefRefPtr<CefProcessMessage> msg =
|
|
|
|
CefProcessMessage::Create(kRenderThreadTestMsg);
|
2019-05-24 22:23:43 +02:00
|
|
|
browser->GetMainFrame()->SendProcessMessage(PID_RENDERER, msg);
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
2019-05-24 22:23:43 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2017-05-17 11:29:28 +02:00
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) override {
|
2016-11-12 00:22:53 +01:00
|
|
|
EXPECT_TRUE(browser.get());
|
2019-05-24 22:23:43 +02:00
|
|
|
EXPECT_TRUE(frame.get());
|
2016-11-12 00:22:53 +01:00
|
|
|
EXPECT_EQ(PID_RENDERER, source_process);
|
|
|
|
EXPECT_TRUE(message.get());
|
|
|
|
EXPECT_TRUE(message->IsReadOnly());
|
|
|
|
|
|
|
|
const std::string& message_name = message->GetName();
|
|
|
|
EXPECT_STREQ(kRenderThreadTestMsg, message_name.c_str());
|
|
|
|
|
|
|
|
got_message_.yes();
|
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (message->GetArgumentList()->GetBool(0)) {
|
2016-11-12 00:22:53 +01:00
|
|
|
got_success_.yes();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
// Test is complete.
|
|
|
|
DestroyTest();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void DestroyTest() override {
|
|
|
|
EXPECT_TRUE(got_message_);
|
|
|
|
EXPECT_TRUE(got_success_);
|
|
|
|
|
|
|
|
TestHandler::DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_message_;
|
|
|
|
TrackCallback got_success_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(RenderThreadTestHandler);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(RenderThreadTestHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Renderer side.
|
|
|
|
class RenderThreadRendererTest : public ClientAppRenderer::Delegate {
|
|
|
|
public:
|
2024-01-20 18:00:09 +01:00
|
|
|
RenderThreadRendererTest() = default;
|
2016-11-12 00:22:53 +01:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OnProcessMessageReceived(CefRefPtr<ClientAppRenderer> app,
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
2019-05-24 22:23:43 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2017-05-17 11:29:28 +02:00
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) override {
|
2016-11-12 00:22:53 +01:00
|
|
|
if (message->GetName().ToString() == kRenderThreadTestMsg) {
|
|
|
|
browser_ = browser;
|
|
|
|
EXPECT_FALSE(thread_test_.get());
|
|
|
|
thread_test_ = new SimpleThreadTest(
|
2021-06-19 21:54:45 +02:00
|
|
|
3, base::DoNothing(),
|
|
|
|
base::BindOnce(&RenderThreadRendererTest::Done, this));
|
2016-11-12 00:22:53 +01:00
|
|
|
thread_test_->RunTest();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Message not handled.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Done() {
|
|
|
|
// Let the call stack unwind before destroying |thread_test_|.
|
|
|
|
CefPostTask(TID_RENDERER,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::BindOnce(&RenderThreadRendererTest::DestroyTest, this));
|
2016-11-12 00:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyTest() {
|
|
|
|
EXPECT_TRUE(thread_test_.get());
|
|
|
|
if (thread_test_) {
|
|
|
|
thread_test_->DestroyTest();
|
|
|
|
thread_test_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the test has failed.
|
|
|
|
bool result = !TestFailed();
|
|
|
|
|
|
|
|
// Return the result to the browser process.
|
|
|
|
CefRefPtr<CefProcessMessage> return_msg =
|
|
|
|
CefProcessMessage::Create(kRenderThreadTestMsg);
|
|
|
|
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
2019-05-24 22:23:43 +02:00
|
|
|
browser_->GetMainFrame()->SendProcessMessage(PID_BROWSER, return_msg);
|
2016-11-12 00:22:53 +01:00
|
|
|
|
|
|
|
browser_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowser> browser_;
|
|
|
|
scoped_refptr<SimpleThreadTest> thread_test_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(RenderThreadRendererTest);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(RenderThreadRendererTest);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TEST(ThreadTest, CreateFromRenderThread) {
|
|
|
|
CefRefPtr<RenderThreadTestHandler> handler = new RenderThreadTestHandler();
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Entry point for creating request handler renderer test objects.
|
|
|
|
// Called from client_app_delegates.cc.
|
2017-05-17 11:29:28 +02:00
|
|
|
void CreateThreadRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
2016-11-12 00:22:53 +01:00
|
|
|
delegates.insert(new RenderThreadRendererTest);
|
|
|
|
}
|