From 450d7a18ffffbaeb8722b2d84ec181fbff7e91bb Mon Sep 17 00:00:00 2001 From: Konstantin Varlamov Date: Fri, 11 May 2018 21:43:25 -0400 Subject: 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). --- .../firestore/util/async_queue_libdispatch_test.mm | 2 +- .../firestore/util/executor_libdispatch_test.mm | 33 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'Firestore/core/test') 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 ExecutorFactory() { - return absl::make_unique(); + return absl::make_unique( + 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; +}; + +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 -- cgit v1.2.3