Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RavelCAPI
Submodule RavelCAPI updated 1 files
+8 −0 ravelState.h
1 change: 1 addition & 0 deletions model/ravelWrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ namespace minsky
{
lockGroup=ravel->lockGroup;
lockGroup->addRavel(ravelPtr);
lockGroup->initialBroadcast();
return true;
}
}
Expand Down
44 changes: 41 additions & 3 deletions test/testLockGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
along with Minsky. If not, see <http://www.gnu.org/licenses/>.
*/

#include "cairoItems.h"
#include "ravelWrap.h"
#include "canvas.h"
#include "minsky.h"
#include "minsky_epilogue.h"

#undef True
Expand All @@ -34,6 +32,8 @@ namespace

class RavelLockGroupTest : public Canvas, public ::testing::Test
{
Minsky minsky; // provides model and selection
LocalMinsky lminsky{minsky};
public:
RavelLockGroupTest() : Canvas(make_shared<Group>()) {}
};
Expand Down Expand Up @@ -95,3 +95,41 @@ TEST_F(RavelLockGroupTest, LockGroup)
EXPECT_TRUE(b->lockGroup==c->lockGroup);
EXPECT_FALSE(d->lockGroup);
}

TEST_F(RavelLockGroupTest, JoinLockGroupBroadcast)
{
auto a=make_shared<Ravel>(), b=make_shared<Ravel>();

// Add ravels to model so joinLockGroup can find them
minsky::minsky().model->addItem(a);
minsky::minsky().model->addItem(b);

// Create a lock group with ravel a and set some state
a->lockGroup.reset(new RavelLockGroup);
a->lockGroup->addRavel(a);
auto colour=a->lockGroup->colour();

// Set calipers on ravel a to have some distinguishable state
auto aState=a->getState();
ASSERT_FALSE(aState.handleStates.empty());
aState.handleStates[0].displayFilterCaliper=true;
aState.handleStates[0].minLabel="1991";
aState.handleStates[0].maxLabel="1991";
a->applyState(aState);

// Verify ravel b has different state
ASSERT_FALSE(b->getState().handleStates.empty());
EXPECT_FALSE(b->getState().handleStates[0].displayFilterCaliper);
EXPECT_NE("1991",b->getState().handleStates[0].minLabel);
EXPECT_NE("1991",b->getState().handleStates[0].maxLabel);

// Now have b join the lock group using joinLockGroup method
b->joinLockGroup(colour);

// Verify both ravels are in the same lock group
EXPECT_EQ(a->lockGroup, b->lockGroup);
EXPECT_EQ(2, a->lockGroup->ravels().size());

// Verify state was broadcast - check if b got a's caliper settings
EXPECT_TRUE(b->getState()==aState);
}
Loading