diff options
author | Konstantin Varlamov <var-const@users.noreply.github.com> | 2018-05-11 21:43:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-11 21:43:25 -0400 |
commit | 450d7a18ffffbaeb8722b2d84ec181fbff7e91bb (patch) | |
tree | 557eb31d4eebb09de046dbdae17ea7f983b6c880 /Firestore/core/test | |
parent | 604de8e947ee8e58094bb2d7cb4cc7ac16e97876 (diff) |
Firestore C++: make FSTDispatchQueue delegate to C++ implementation (#1240)
FSTDispatchQueue now doesn't contain any logic of its own and instead
just passes through all method calls to AsyncQueue (backed by an
ExecutorLibdispatch).
Diffstat (limited to 'Firestore/core/test')
-rw-r--r-- | Firestore/core/test/firebase/firestore/util/async_queue_libdispatch_test.mm | 2 | ||||
-rw-r--r-- | Firestore/core/test/firebase/firestore/util/executor_libdispatch_test.mm | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/Firestore/core/test/firebase/firestore/util/async_queue_libdispatch_test.mm b/Firestore/core/test/firebase/firestore/util/async_queue_libdispatch_test.mm index 5452266..f1ff394 100644 --- a/Firestore/core/test/firebase/firestore/util/async_queue_libdispatch_test.mm +++ b/Firestore/core/test/firebase/firestore/util/async_queue_libdispatch_test.mm @@ -77,7 +77,7 @@ TEST_F(AsyncQueueTestLibdispatchOnly, } TEST_F(AsyncQueueTestLibdispatchOnly, - VerifyIsCurrentQueueRequiresBeingCalledAsync) { + VerifyIsCurrentQueueRequiresBeingCalledOnTheQueue) { ASSERT_NE(underlying_queue, dispatch_get_main_queue()); EXPECT_ANY_THROW(queue.VerifyIsCurrentQueue()); } diff --git a/Firestore/core/test/firebase/firestore/util/executor_libdispatch_test.mm b/Firestore/core/test/firebase/firestore/util/executor_libdispatch_test.mm index 0167c83..330c8fc 100644 --- a/Firestore/core/test/firebase/firestore/util/executor_libdispatch_test.mm +++ b/Firestore/core/test/firebase/firestore/util/executor_libdispatch_test.mm @@ -29,7 +29,8 @@ namespace util { namespace { std::unique_ptr<internal::Executor> ExecutorFactory() { - return absl::make_unique<internal::ExecutorLibdispatch>(); + return absl::make_unique<internal::ExecutorLibdispatch>( + dispatch_queue_create("ExecutorLibdispatchTests", DISPATCH_QUEUE_SERIAL)); } } // namespace @@ -38,6 +39,36 @@ INSTANTIATE_TEST_CASE_P(ExecutorTestLibdispatch, ExecutorTest, ::testing::Values(ExecutorFactory)); +namespace internal { +class ExecutorLibdispatchOnlyTests : public TestWithTimeoutMixin, + public ::testing::Test { + public: + ExecutorLibdispatchOnlyTests() : executor{ExecutorFactory()} { + } + + std::unique_ptr<Executor> executor; +}; + +TEST_F(ExecutorLibdispatchOnlyTests, NameReturnsLabelOfTheQueue) { + EXPECT_EQ(executor->Name(), "ExecutorLibdispatchTests"); + executor->Execute([&] { + EXPECT_EQ(executor->CurrentExecutorName(), "ExecutorLibdispatchTests"); + signal_finished(); + }); + EXPECT_TRUE(WaitForTestToFinish()); +} + +TEST_F(ExecutorLibdispatchOnlyTests, + ExecuteBlockingOnTheCurrentQueueIsNotAllowed) { + EXPECT_NO_THROW(executor->ExecuteBlocking([] {})); + executor->Execute([&] { + EXPECT_ANY_THROW(executor->ExecuteBlocking([] {})); + signal_finished(); + }); + EXPECT_TRUE(WaitForTestToFinish()); +} + +} // namespace internal } // namespace util } // namespace firestore } // namespace firebase |