summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-16 13:48:33 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-15 09:56:18 -0700
commit6e78eabfff75579286ab23cbde8a36fba061ca1d (patch)
tree2437392712213f97c0326cce8691a6944fb72734 /test
parent253a007d99c2079b95d5c6d11715e16815067e16 (diff)
downloadqtlocation-mapboxgl-6e78eabfff75579286ab23cbde8a36fba061ca1d.tar.gz
[core] Clean up ThreadContext vestiges
Diffstat (limited to 'test')
-rw-r--r--test/map/map_context.cpp2
-rw-r--r--test/storage/asset_file_source.cpp2
-rw-r--r--test/style/glyph_store.cpp3
-rw-r--r--test/style/source.cpp3
-rw-r--r--test/style/style.cpp4
-rw-r--r--test/util/async_task.cpp4
-rw-r--r--test/util/thread.cpp22
-rw-r--r--test/util/thread_local.cpp4
-rw-r--r--test/util/work_queue.cpp6
9 files changed, 14 insertions, 36 deletions
diff --git a/test/map/map_context.cpp b/test/map/map_context.cpp
index 47777d262e..be7e2abb8a 100644
--- a/test/map/map_context.cpp
+++ b/test/map/map_context.cpp
@@ -17,7 +17,7 @@ TEST(MapContext, DoubleStyleLoad) {
HeadlessView view(display, 1, 512, 512);
StubFileSource fileSource;
- util::Thread<MapContext> context({"Map", util::ThreadType::Map, util::ThreadPriority::Regular},
+ util::Thread<MapContext> context({"Map"},
view, fileSource, MapMode::Continuous, GLContextMode::Unique, view.getPixelRatio());
context.invokeSync(&MapContext::setStyleJSON, "", "");
diff --git a/test/storage/asset_file_source.cpp b/test/storage/asset_file_source.cpp
index 4a9866601a..64f7254807 100644
--- a/test/storage/asset_file_source.cpp
+++ b/test/storage/asset_file_source.cpp
@@ -73,7 +73,7 @@ TEST(AssetFileSource, Stress) {
std::vector<std::unique_ptr<util::Thread<TestWorker>>> threads;
std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
- util::ThreadContext context = { "Test", util::ThreadType::Map, util::ThreadPriority::Regular };
+ util::ThreadContext context = { "Test" };
for (unsigned i = 0; i < numThreads; ++i) {
std::unique_ptr<util::Thread<TestWorker>> thread =
diff --git a/test/style/glyph_store.cpp b/test/style/glyph_store.cpp
index 126317e7ad..c101d45bdf 100644
--- a/test/style/glyph_store.cpp
+++ b/test/style/glyph_store.cpp
@@ -13,7 +13,6 @@ using namespace mbgl;
class GlyphStoreTest {
public:
- util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
util::RunLoop loop;
StubFileSource fileSource;
StubStyleObserver observer;
@@ -23,8 +22,6 @@ public:
// Squelch logging.
Log::setObserver(std::make_unique<Log::NullObserver>());
- util::ThreadContext::Set(&context);
-
glyphStore.setObserver(&observer);
glyphStore.setURL(url);
glyphStore.hasGlyphRanges(fontStack, glyphRanges);
diff --git a/test/style/source.cpp b/test/style/source.cpp
index 73367f639f..9c334c65d5 100644
--- a/test/style/source.cpp
+++ b/test/style/source.cpp
@@ -21,7 +21,6 @@ using namespace mbgl;
class SourceTest {
public:
- util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
util::RunLoop loop;
StubFileSource fileSource;
StubStyleObserver observer;
@@ -51,8 +50,6 @@ public:
// Squelch logging.
Log::setObserver(std::make_unique<Log::NullObserver>());
- util::ThreadContext::Set(&context);
-
transform.resize({{ 512, 512 }});
transform.setLatLngZoom({0, 0}, 0);
diff --git a/test/style/style.cpp b/test/style/style.cpp
index 4b01b0a146..03e044ba76 100644
--- a/test/style/style.cpp
+++ b/test/style/style.cpp
@@ -9,8 +9,6 @@ using namespace mbgl;
TEST(Style, UnusedSource) {
util::RunLoop loop;
- util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
- util::ThreadContext::Set(&context);
MapData data { MapMode::Still, GLContextMode::Unique, 1.0 };
StubFileSource fileSource;
@@ -33,8 +31,6 @@ TEST(Style, UnusedSource) {
TEST(Style, UnusedSourceActiveViaClassUpdate) {
util::RunLoop loop;
- util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
- util::ThreadContext::Set(&context);
MapData data { MapMode::Still, GLContextMode::Unique, 1.0 };
StubFileSource fileSource;
diff --git a/test/util/async_task.cpp b/test/util/async_task.cpp
index 5fd890ad9e..ad65bfad78 100644
--- a/test/util/async_task.cpp
+++ b/test/util/async_task.cpp
@@ -98,7 +98,7 @@ TEST(AsyncTask, RequestCoalescingMultithreaded) {
AsyncTask async([&count] { ++count; });
std::vector<std::unique_ptr<Thread<TestWorker>>> threads;
- ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular};
+ ThreadContext context = {"Test"};
unsigned numThreads = 25;
for (unsigned i = 0; i < numThreads; ++i) {
@@ -133,7 +133,7 @@ TEST(AsyncTask, ThreadSafety) {
std::vector<std::unique_ptr<Thread<TestWorker>>> threads;
std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
- ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular};
+ ThreadContext context = {"Test"};
for (unsigned i = 0; i < numThreads; ++i) {
std::unique_ptr<Thread<TestWorker>> thread =
diff --git a/test/util/thread.cpp b/test/util/thread.cpp
index 9414d14f3c..bf76ec4aef 100644
--- a/test/util/thread.cpp
+++ b/test/util/thread.cpp
@@ -55,9 +55,7 @@ public:
}
void checkContext(std::function<void (bool)> cb) const {
- cb(ThreadContext::currentlyOn(ThreadType::Worker)
- && ThreadContext::getName() == "Test"
- && ThreadContext::getPriority() == ThreadPriority::Low);
+ cb(tid == std::this_thread::get_id());
}
const std::thread::id tid;
@@ -71,7 +69,7 @@ TEST(Thread, invoke) {
loop.invoke([&] {
EXPECT_EQ(tid, std::this_thread::get_id());
- Thread<TestObject> thread({"Test", ThreadType::Map, ThreadPriority::Regular}, tid);
+ Thread<TestObject> thread({"Test"}, tid);
thread.invoke(&TestObject::fn1, 1);
requests.push_back(thread.invokeWithCallback(&TestObject::fn2, [&] (int result) {
@@ -114,19 +112,13 @@ TEST(Thread, invoke) {
}
TEST(Thread, context) {
- bool isMainThreadContext = ThreadContext::currentlyOn(ThreadType::Main)
- && ThreadContext::getName() == "Main"
- && ThreadContext::getPriority() == ThreadPriority::Regular;
-
- EXPECT_EQ(isMainThreadContext, true);
-
const std::thread::id tid = std::this_thread::get_id();
RunLoop loop;
std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
loop.invoke([&] {
- Thread<TestObject> thread({"Test", ThreadType::Worker, ThreadPriority::Low}, tid);
+ Thread<TestObject> thread({"Test"}, tid);
requests.push_back(thread.invokeWithCallback(&TestObject::checkContext, [&] (bool inTestThreadContext) {
EXPECT_EQ(inTestThreadContext, true);
@@ -149,7 +141,7 @@ public:
TEST(Thread, ExecutesAfter) {
RunLoop loop;
- Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular});
+ Thread<TestWorker> thread({"Test"});
bool didWork = false;
bool didAfter = false;
@@ -170,7 +162,7 @@ TEST(Thread, ExecutesAfter) {
TEST(Thread, WorkRequestDeletionWaitsForWorkToComplete) {
RunLoop loop;
- Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular});
+ Thread<TestWorker> thread({"Test"});
std::promise<void> started;
bool didWork = false;
@@ -188,7 +180,7 @@ TEST(Thread, WorkRequestDeletionWaitsForWorkToComplete) {
TEST(Thread, WorkRequestDeletionCancelsAfter) {
RunLoop loop;
- Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular});
+ Thread<TestWorker> thread({"Test"});
std::promise<void> started;
bool didAfter = false;
@@ -207,7 +199,7 @@ TEST(Thread, WorkRequestDeletionCancelsAfter) {
TEST(Thread, WorkRequestDeletionCancelsImmediately) {
RunLoop loop;
- Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular});
+ Thread<TestWorker> thread({"Test"});
std::promise<void> started;
diff --git a/test/util/thread_local.cpp b/test/util/thread_local.cpp
index 98b3948fc8..074af2c5d0 100644
--- a/test/util/thread_local.cpp
+++ b/test/util/thread_local.cpp
@@ -37,7 +37,7 @@ TEST(ThreadLocalStorage, Basic) {
int number2 = 2;
int number3 = 3;
- ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular};
+ ThreadContext context = {"Test"};
Thread<TestThread> thread1(context, &number1);
Thread<TestThread> thread2(context, &number2);
@@ -83,7 +83,7 @@ TEST(ThreadLocalStorage, AutoReclaim) {
DtorCounter* dtorCounter1 = new DtorCounter{ &counter };
DtorCounter* dtorCounter2 = new DtorCounter{ &counter };
- ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular};
+ ThreadContext context = {"Test"};
auto thread1 = std::make_unique<Thread<TestThreadReclaim>>(context, dtorCounter1);
auto thread2 = std::make_unique<Thread<TestThreadReclaim>>(context, dtorCounter2);
diff --git a/test/util/work_queue.cpp b/test/util/work_queue.cpp
index c8cce4f97b..60c72f7358 100644
--- a/test/util/work_queue.cpp
+++ b/test/util/work_queue.cpp
@@ -13,8 +13,6 @@ public:
TestThread(WorkQueue* queue_) : queue(queue_) {}
void send(std::function<void()>&& fn) {
- EXPECT_TRUE(ThreadContext::currentlyOn(ThreadType::Map));
-
queue->push(std::move(fn));
}
@@ -26,13 +24,11 @@ TEST(WorkQueue, push) {
RunLoop loop;
WorkQueue queue;
- Thread<TestThread> thread({"Test", ThreadType::Map, ThreadPriority::Regular}, &queue);
+ Thread<TestThread> thread({"Test"}, &queue);
uint8_t count = 0;
auto endTest = [&]() {
- EXPECT_TRUE(ThreadContext::currentlyOn(ThreadType::Main));
-
if (++count == 4) {
loop.stop();
}