2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 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"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "include/cef_command_line.h"
|
2013-01-03 18:24:24 +01:00
|
|
|
#include "include/cef_task.h"
|
2016-03-16 03:55:59 +01:00
|
|
|
#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"
|
2013-01-03 18:24:24 +01:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
void WaitForEvent(CefRefPtr<CefWaitableEvent> event) {
|
|
|
|
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
|
|
|
|
"disable-test-timeout")) {
|
|
|
|
event->Wait();
|
|
|
|
} else {
|
|
|
|
EXPECT_TRUE(event->TimedWait(1000));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetForCurrentThread(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
2016-11-15 22:18:41 +01:00
|
|
|
// Currently on the FILE thread.
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefTaskRunner> runner = CefTaskRunner::GetForCurrentThread();
|
|
|
|
EXPECT_TRUE(runner.get());
|
|
|
|
EXPECT_TRUE(runner->BelongsToCurrentThread());
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_FILE_USER_VISIBLE));
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_FALSE(runner->BelongsToThread(TID_IO));
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner->IsSame(runner));
|
|
|
|
|
|
|
|
CefRefPtr<CefTaskRunner> runner2 = CefTaskRunner::GetForCurrentThread();
|
|
|
|
EXPECT_TRUE(runner2.get());
|
|
|
|
EXPECT_TRUE(runner->IsSame(runner2));
|
|
|
|
EXPECT_TRUE(runner2->IsSame(runner));
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
// Not on the IO thread.
|
|
|
|
CefRefPtr<CefTaskRunner> runner3 = CefTaskRunner::GetForThread(TID_IO);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner3.get());
|
|
|
|
EXPECT_FALSE(runner->IsSame(runner3));
|
|
|
|
EXPECT_FALSE(runner3->IsSame(runner));
|
|
|
|
|
|
|
|
*ran_test = true;
|
2018-03-20 21:15:08 +01:00
|
|
|
event->Signal();
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
void GetForThread(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
2016-11-15 22:18:41 +01:00
|
|
|
// Currently on the FILE thread.
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefTaskRunner> runner = CefTaskRunner::GetForThread(TID_IO);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner.get());
|
|
|
|
EXPECT_FALSE(runner->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_IO));
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_FALSE(runner->BelongsToThread(TID_FILE_USER_VISIBLE));
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner->IsSame(runner));
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefTaskRunner> runner2 = CefTaskRunner::GetForThread(TID_IO);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner2.get());
|
|
|
|
EXPECT_TRUE(runner->IsSame(runner2));
|
|
|
|
EXPECT_TRUE(runner2->IsSame(runner));
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
CefRefPtr<CefTaskRunner> runner3 =
|
|
|
|
CefTaskRunner::GetForThread(TID_FILE_USER_VISIBLE);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner3.get());
|
|
|
|
EXPECT_FALSE(runner->IsSame(runner3));
|
|
|
|
EXPECT_FALSE(runner3->IsSame(runner));
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
*ran_test = true;
|
2018-03-20 21:15:08 +01:00
|
|
|
event->Signal();
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
void PostTaskEvent1(bool* ran_test,
|
|
|
|
CefRefPtr<CefWaitableEvent> event,
|
|
|
|
CefRefPtr<CefTaskRunner> runner) {
|
|
|
|
// Currently on the IO thread.
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_IO));
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_FALSE(runner->BelongsToThread(TID_FILE_USER_VISIBLE));
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
// Current thread should be the IO thread.
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefTaskRunner> runner2 = CefTaskRunner::GetForCurrentThread();
|
|
|
|
EXPECT_TRUE(runner2.get());
|
|
|
|
EXPECT_TRUE(runner2->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_TRUE(runner2->BelongsToThread(TID_IO));
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_FALSE(runner2->BelongsToThread(TID_FILE_USER_VISIBLE));
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner->IsSame(runner2));
|
|
|
|
EXPECT_TRUE(runner2->IsSame(runner));
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
// Current thread should be the IO thread.
|
|
|
|
CefRefPtr<CefTaskRunner> runner3 = CefTaskRunner::GetForThread(TID_IO);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner3.get());
|
|
|
|
EXPECT_TRUE(runner3->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_TRUE(runner3->BelongsToThread(TID_IO));
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_FALSE(runner3->BelongsToThread(TID_FILE_USER_VISIBLE));
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner->IsSame(runner3));
|
|
|
|
EXPECT_TRUE(runner3->IsSame(runner));
|
|
|
|
|
2016-11-15 22:18:41 +01:00
|
|
|
// Current thread should not be the FILE thread.
|
2020-09-25 03:40:47 +02:00
|
|
|
CefRefPtr<CefTaskRunner> runner4 =
|
|
|
|
CefTaskRunner::GetForThread(TID_FILE_USER_VISIBLE);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner4.get());
|
|
|
|
EXPECT_FALSE(runner4->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_FALSE(runner4->BelongsToThread(TID_IO));
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_TRUE(runner4->BelongsToThread(TID_FILE_USER_VISIBLE));
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_FALSE(runner->IsSame(runner4));
|
|
|
|
EXPECT_FALSE(runner4->IsSame(runner));
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
*ran_test = true;
|
|
|
|
event->Signal();
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
void PostOnceTask1(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
2016-11-15 22:18:41 +01:00
|
|
|
// Currently on the FILE thread.
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefTaskRunner> runner = CefTaskRunner::GetForThread(TID_IO);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner.get());
|
|
|
|
EXPECT_FALSE(runner->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_IO));
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
runner->PostTask(CefCreateClosureTask(
|
2021-06-18 20:19:11 +02:00
|
|
|
base::BindOnce(&PostTaskEvent1, ran_test, event, runner)));
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
void PostRepeatingTask1(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
2016-11-15 22:18:41 +01:00
|
|
|
// Currently on the FILE thread.
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefTaskRunner> runner = CefTaskRunner::GetForThread(TID_IO);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(runner.get());
|
|
|
|
EXPECT_FALSE(runner->BelongsToCurrentThread());
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_IO));
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
runner->PostTask(CefCreateClosureTask(
|
|
|
|
base::BindRepeating(&PostTaskEvent1, ran_test, event, runner)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PostOnceDelayedTask1(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
|
|
|
// Currently on the FILE thread.
|
|
|
|
CefRefPtr<CefTaskRunner> runner = CefTaskRunner::GetForThread(TID_IO);
|
|
|
|
EXPECT_TRUE(runner.get());
|
|
|
|
EXPECT_FALSE(runner->BelongsToCurrentThread());
|
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_IO));
|
|
|
|
|
|
|
|
runner->PostDelayedTask(CefCreateClosureTask(base::BindOnce(
|
|
|
|
&PostTaskEvent1, ran_test, event, runner)),
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PostRepeatingDelayedTask1(bool* ran_test,
|
|
|
|
CefRefPtr<CefWaitableEvent> event) {
|
|
|
|
// Currently on the FILE thread.
|
|
|
|
CefRefPtr<CefTaskRunner> runner = CefTaskRunner::GetForThread(TID_IO);
|
|
|
|
EXPECT_TRUE(runner.get());
|
|
|
|
EXPECT_FALSE(runner->BelongsToCurrentThread());
|
|
|
|
EXPECT_TRUE(runner->BelongsToThread(TID_IO));
|
|
|
|
|
|
|
|
runner->PostDelayedTask(CefCreateClosureTask(base::BindRepeating(
|
2018-03-20 21:15:08 +01:00
|
|
|
&PostTaskEvent1, ran_test, event, runner)),
|
|
|
|
0);
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
void PostTaskEvent2(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
|
|
|
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
|
2020-09-25 03:40:47 +02:00
|
|
|
EXPECT_FALSE(CefCurrentlyOn(TID_FILE_USER_VISIBLE));
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
*ran_test = true;
|
|
|
|
event->Signal();
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
void PostOnceTask2(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
2016-11-15 22:18:41 +01:00
|
|
|
// Currently on the FILE thread.
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_FALSE(CefCurrentlyOn(TID_IO));
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
CefPostTask(TID_IO, CefCreateClosureTask(
|
2021-06-18 20:19:11 +02:00
|
|
|
base::BindOnce(&PostTaskEvent2, ran_test, event)));
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
void PostRepeatingTask2(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
|
|
|
// Currently on the FILE thread.
|
|
|
|
EXPECT_FALSE(CefCurrentlyOn(TID_IO));
|
|
|
|
|
|
|
|
CefPostTask(TID_IO, CefCreateClosureTask(base::BindRepeating(
|
|
|
|
&PostTaskEvent2, ran_test, event)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PostOnceDelayedTask2(bool* ran_test, CefRefPtr<CefWaitableEvent> event) {
|
2016-11-15 22:18:41 +01:00
|
|
|
// Currently on the FILE thread.
|
2018-03-20 21:15:08 +01:00
|
|
|
EXPECT_FALSE(CefCurrentlyOn(TID_IO));
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPostDelayedTask(
|
2018-03-20 21:15:08 +01:00
|
|
|
TID_IO,
|
2021-06-18 20:19:11 +02:00
|
|
|
CefCreateClosureTask(base::BindOnce(&PostTaskEvent2, ran_test, event)),
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PostRepeatingDelayedTask2(bool* ran_test,
|
|
|
|
CefRefPtr<CefWaitableEvent> event) {
|
|
|
|
// Currently on the FILE thread.
|
|
|
|
EXPECT_FALSE(CefCurrentlyOn(TID_IO));
|
|
|
|
|
|
|
|
CefPostDelayedTask(TID_IO,
|
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindRepeating(&PostTaskEvent2, ran_test, event)),
|
|
|
|
0);
|
2013-01-03 18:24:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
TEST(TaskTest, GetOnceForCurrentThread) {
|
|
|
|
bool ran_test = false;
|
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindOnce(&GetForCurrentThread, &ran_test, event)));
|
|
|
|
WaitForEvent(event);
|
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TaskTest, GetRepeatingForCurrentThread) {
|
|
|
|
bool ran_test = false;
|
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindRepeating(&GetForCurrentThread, &ran_test, event)));
|
|
|
|
WaitForEvent(event);
|
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TaskTest, GetOnceForThread) {
|
2013-01-03 18:24:24 +01:00
|
|
|
bool ran_test = false;
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
2021-06-18 20:19:11 +02:00
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE, CefCreateClosureTask(base::BindOnce(
|
|
|
|
&GetForThread, &ran_test, event)));
|
2018-03-20 21:15:08 +01:00
|
|
|
WaitForEvent(event);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
TEST(TaskTest, GetRepeatingForThread) {
|
2013-01-03 18:24:24 +01:00
|
|
|
bool ran_test = false;
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
2021-06-18 20:19:11 +02:00
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE, CefCreateClosureTask(base::BindRepeating(
|
2020-09-25 03:40:47 +02:00
|
|
|
&GetForThread, &ran_test, event)));
|
2018-03-20 21:15:08 +01:00
|
|
|
WaitForEvent(event);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
TEST(TaskTest, PostOnceTask1) {
|
|
|
|
bool ran_test = false;
|
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE, CefCreateClosureTask(base::BindOnce(
|
|
|
|
&PostOnceTask1, &ran_test, event)));
|
|
|
|
WaitForEvent(event);
|
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TaskTest, PostRepeatingTask1) {
|
2013-01-03 18:24:24 +01:00
|
|
|
bool ran_test = false;
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
2020-09-25 03:40:47 +02:00
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
2021-06-18 20:19:11 +02:00
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindRepeating(&PostRepeatingTask1, &ran_test, event)));
|
2018-03-20 21:15:08 +01:00
|
|
|
WaitForEvent(event);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
TEST(TaskTest, PostOnceDelayedTask1) {
|
2013-01-03 18:24:24 +01:00
|
|
|
bool ran_test = false;
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
2021-06-18 20:19:11 +02:00
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindOnce(&PostOnceDelayedTask1, &ran_test, event)));
|
2018-03-20 21:15:08 +01:00
|
|
|
WaitForEvent(event);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
TEST(TaskTest, PostRepeatingDelayedTask1) {
|
2013-01-03 18:24:24 +01:00
|
|
|
bool ran_test = false;
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
2020-09-25 03:40:47 +02:00
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
2021-06-18 20:19:11 +02:00
|
|
|
CefCreateClosureTask(base::BindRepeating(
|
|
|
|
&PostRepeatingDelayedTask1, &ran_test, event)));
|
2018-03-20 21:15:08 +01:00
|
|
|
WaitForEvent(event);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
2021-06-18 20:19:11 +02:00
|
|
|
TEST(TaskTest, PostOnceTask2) {
|
2013-01-03 18:24:24 +01:00
|
|
|
bool ran_test = false;
|
2018-03-20 21:15:08 +01:00
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
2021-06-18 20:19:11 +02:00
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE, CefCreateClosureTask(base::BindOnce(
|
|
|
|
&PostOnceTask2, &ran_test, event)));
|
|
|
|
WaitForEvent(event);
|
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TaskTest, PostRepeatingTask2) {
|
|
|
|
bool ran_test = false;
|
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindRepeating(&PostRepeatingTask2, &ran_test, event)));
|
|
|
|
WaitForEvent(event);
|
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TaskTest, PostOnceDelayedTask2) {
|
|
|
|
bool ran_test = false;
|
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
|
|
|
CefCreateClosureTask(
|
|
|
|
base::BindOnce(&PostOnceDelayedTask2, &ran_test, event)));
|
|
|
|
WaitForEvent(event);
|
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TaskTest, PostRepeatingDelayedTask2) {
|
|
|
|
bool ran_test = false;
|
|
|
|
CefRefPtr<CefWaitableEvent> event =
|
|
|
|
CefWaitableEvent::CreateWaitableEvent(true, false);
|
|
|
|
CefPostTask(TID_FILE_USER_VISIBLE,
|
|
|
|
CefCreateClosureTask(base::BindRepeating(
|
|
|
|
&PostRepeatingDelayedTask2, &ran_test, event)));
|
2018-03-20 21:15:08 +01:00
|
|
|
WaitForEvent(event);
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(ran_test);
|
|
|
|
}
|