Flutter Engine
sync_switch_unittest.cc File Reference
#include "flutter/fml/synchronization/sync_switch.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (SyncSwitchTest, Basic)
 
 TEST (SyncSwitchTest, NoopIfUndefined)
 

Function Documentation

◆ TEST() [1/2]

TEST ( SyncSwitchTest  ,
Basic   
)

Definition at line 11 of file sync_switch_unittest.cc.

References fml::SyncSwitch::Execute(), and fml::SyncSwitch::SetSwitch().

11  {
12  SyncSwitch syncSwitch;
13  bool switchValue = false;
14  syncSwitch.Execute(SyncSwitch::Handlers()
15  .SetIfTrue([&] { switchValue = true; })
16  .SetIfFalse([&] { switchValue = false; }));
17  EXPECT_FALSE(switchValue);
18  syncSwitch.SetSwitch(true);
19  syncSwitch.Execute(SyncSwitch::Handlers()
20  .SetIfTrue([&] { switchValue = true; })
21  .SetIfFalse([&] { switchValue = false; }));
22  EXPECT_TRUE(switchValue);
23 }
void SetSwitch(bool value)
Definition: sync_switch.cc:34
void Execute(const Handlers &handlers)
Definition: sync_switch.cc:25

◆ TEST() [2/2]

TEST ( SyncSwitchTest  ,
NoopIfUndefined   
)

Definition at line 25 of file sync_switch_unittest.cc.

References fml::SyncSwitch::Execute().

25  {
26  SyncSwitch syncSwitch;
27  bool switchValue = false;
28  syncSwitch.Execute(SyncSwitch::Handlers());
29  EXPECT_FALSE(switchValue);
30 }
void Execute(const Handlers &handlers)
Definition: sync_switch.cc:25