Rename the sixtyfps C++ namespaces

This commit is contained in:
Simon Hausmann 2022-02-02 11:39:24 +01:00
parent 5226feab01
commit 7d297da2fc
96 changed files with 747 additions and 753 deletions

View file

@ -9,35 +9,35 @@
TEST_CASE("C++ Singleshot Timers")
{
using namespace sixtyfps;
using namespace slint;
int called = 0;
Timer testTimer(std::chrono::milliseconds(16), [&]() {
sixtyfps::quit_event_loop();
slint::quit_event_loop();
called += 10;
});
REQUIRE(called == 0);
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 10);
}
TEST_CASE("C++ Repeated Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -46,32 +46,32 @@ TEST_CASE("C++ Repeated Timer")
TEST_CASE("C++ Restart Singleshot Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::SingleShot, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::SingleShot, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 1);
REQUIRE(timer_was_running);
timer_triggered = 0;
timer.restart();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 1);
REQUIRE(timer_was_running);
@ -80,21 +80,21 @@ TEST_CASE("C++ Restart Singleshot Timer")
TEST_CASE("C++ Restart Repeated Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -102,12 +102,12 @@ TEST_CASE("C++ Restart Repeated Timer")
timer_was_running = false;
timer_triggered = 0;
timer.stop();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 0);
REQUIRE(!timer_was_running);
@ -117,12 +117,12 @@ TEST_CASE("C++ Restart Repeated Timer")
timer.restart();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -131,12 +131,12 @@ TEST_CASE("C++ Restart Repeated Timer")
TEST_CASE("Quit from event")
{
int called = 0;
sixtyfps::invoke_from_event_loop([&] {
sixtyfps::quit_event_loop();
slint::invoke_from_event_loop([&] {
slint::quit_event_loop();
called += 10;
});
REQUIRE(called == 0);
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 10);
}
@ -145,13 +145,13 @@ TEST_CASE("Event from thread")
std::atomic<int> called = 0;
auto t = std::thread([&] {
called += 10;
sixtyfps::invoke_from_event_loop([&] {
slint::invoke_from_event_loop([&] {
called += 100;
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 110);
t.join();
}
@ -161,18 +161,18 @@ TEST_CASE("Blocking Event from thread")
std::atomic<int> called = 0;
auto t = std::thread([&] {
// test returning a, unique_ptr because it is movable-only
std::unique_ptr foo = sixtyfps::blocking_invoke_from_event_loop(
[&] { return std::make_unique<int>(42); });
std::unique_ptr foo =
slint::blocking_invoke_from_event_loop([&] { return std::make_unique<int>(42); });
called = *foo;
int xxx = 123;
sixtyfps::blocking_invoke_from_event_loop([&] {
sixtyfps::quit_event_loop();
slint::blocking_invoke_from_event_loop([&] {
slint::quit_event_loop();
xxx = 888999;
});
REQUIRE(xxx == 888999);
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 42);
t.join();
}