Flutter Engine
semaphore_unittest.cc File Reference
#include "flutter/fml/synchronization/semaphore.h"
#include <thread>
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (SemaphoreTest, SimpleValidity)
 
 TEST (SemaphoreTest, WaitOnZero)
 
 TEST (SemaphoreTest, WaitOnZeroSignalThenWait)
 

Function Documentation

◆ TEST() [1/3]

TEST ( SemaphoreTest  ,
SimpleValidity   
)

Definition at line 11 of file semaphore_unittest.cc.

References fml::Semaphore::IsValid().

11  {
12  fml::Semaphore sem(100);
13  ASSERT_TRUE(sem.IsValid());
14 }

◆ TEST() [2/3]

TEST ( SemaphoreTest  ,
WaitOnZero   
)

Definition at line 16 of file semaphore_unittest.cc.

References fml::Semaphore::TryWait().

16  {
17  fml::Semaphore sem(0);
18  ASSERT_FALSE(sem.TryWait());
19 }

◆ TEST() [3/3]

TEST ( SemaphoreTest  ,
WaitOnZeroSignalThenWait   
)

Definition at line 21 of file semaphore_unittest.cc.

References fml::Semaphore::Signal(), and fml::Semaphore::TryWait().

21  {
22  fml::Semaphore sem(0);
23  ASSERT_FALSE(sem.TryWait());
24  std::thread thread([&sem]() { sem.Signal(); });
25  thread.join();
26  ASSERT_TRUE(sem.TryWait());
27  ASSERT_FALSE(sem.TryWait());
28 }