Skip to content

Commit

Permalink
added connection.isConnected and disconnect return test
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Mar 19, 2019
1 parent 2587e84 commit e152268
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/controllerengine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,35 @@ TEST_F(ControllerEngineTest, connectionObject_Disconnect) {
// The counter should have been incremented exactly once.
EXPECT_DOUBLE_EQ(1.0, pass->get());
}
TEST_F(ControllerEngineTest, connectionObject_reflectDisconnect) {
// Test that checks if disconnecting yields the appropriate feedback
auto co = std::make_unique<ControlObject>(ConfigKey("[Test]", "co"));
auto pass = std::make_unique<ControlObject>(ConfigKey("[Test]", "passed"));

ScopedTemporaryFile script(makeTemporaryFile(
"var reaction = function(success) { "
" if (success) {"
" var pass = engine.getValue('[Test]', 'passed');"
" engine.setValue('[Test]', 'passed', pass + 1.0); "
" }"
"};"
"var dummy_callback = function(value) {};"
"var connection = engine.makeConnection('[Test]', 'co', dummy_callback);"
"reaction(connection);"
"reaction(connection.isConnected);"
"var successful_disconnect = connection.disconnect();"
"reaction(successful_disconnect);"
"reaction(!connection.isConnected);"
));
cEngine->evaluate(script->fileName());
EXPECT_FALSE(cEngine->hasErrors(script->fileName()));
// ControlObjectScript connections are processed via QueuedConnection. Use
// processEvents() to cause Qt to deliver them.
application()->processEvents();
// The counter should have been incremented exactly once.
EXPECT_DOUBLE_EQ(4.0, pass->get());
}


TEST_F(ControllerEngineTest, connectionObject_DisconnectByPassingToConnectControl) {
// Test that passing a connection object back to engine.connectControl
Expand Down Expand Up @@ -563,6 +592,7 @@ TEST_F(ControllerEngineTest, connectionObject_trigger) {
EXPECT_DOUBLE_EQ(1.0, counter->get());
}


TEST_F(ControllerEngineTest, connectionExecutesWithCorrectThisObject) {
// Test that callback functions are executed with JavaScript's
// 'this' keyword referring to the object in which the connection
Expand Down

0 comments on commit e152268

Please sign in to comment.