return anObjects;
}
+/**
+ Test move up algorithm.
+*/
void test_HYDROGUI_ZLevelsModel::testMoveUp()
{
HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel();
aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ZLevelsModel::OpType anUp = HYDROGUI_ZLevelsModel::Up;
+ // 0. Check the initial state
CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+ // 1. [ *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ *A, B ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ *A, *C ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 4. [ *A, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 5. [ F ] X 6 times / ALL OBJECTS
+ aModel->move( QList<int>() << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, F, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 4, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, F, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 3, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, F, *C, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 2, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, B, *C, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 1, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 0, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
+
+ // 6. [ *A, B ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, F, *C, D, *E" ), GetObjects( aModel ) );
+
+ // 7. [ B, *C, *E ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 3 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *A, *C, F, *E, D" ), GetObjects( aModel ) );
+
+ // 8. [ *A, *C, F, *E, D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3 << 4 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, F, *E, D, B" ), GetObjects( aModel ) );
+
+ // 9. [ *E ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 3, anUp, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *E, *C, F, D, B" ), GetObjects( aModel ) );
+
+ // 10. [ *E, *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1 << 2, anUp, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *C, *A, F, D, B" ), GetObjects( aModel ) );
+
+ // 11. [ *A, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 2 << 3, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *A, F, *C, D, B" ), GetObjects( aModel ) );
+
+ // 12. [ *A, *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1 << 3, anUp, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B" ), GetObjects( aModel ) );
+
+ // 13. [] / ALL OBJECTS
+ aModel->move( QList<int>(), anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B"), GetObjects( aModel ) );
+
+ // 14. [ *A, *C, *E, F, D, B ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, anUp, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, *C, *E, F, D, B"), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test move on top algorithm.
+*/
+void test_HYDROGUI_ZLevelsModel::testMoveOnTop()
+{
+ HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ZLevelsModel::OpType aTop = HYDROGUI_ZLevelsModel::Top;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 0, aTop, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 5, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *A, B, *C, D, *E" ), GetObjects( aModel ) );
+
+ // 4. [ *E ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 5, aTop, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
+
+ // 5. [ *E, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
+
+ // 6. [ *E, *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *A, F, B, *C, D" ), GetObjects( aModel ) );
+
+ // 7. [ *A, F, *C ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 4, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, F, *C, *E, B, D" ), GetObjects( aModel ) );
+
+ // 8. [ F, *C, *E, B, D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3 << 4 << 5, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
+
+ // 9. [] / ALL OBJECTS
+ aModel->move( QList<int>(), aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
+
+ // 10. [*F, *C, *E, B, D, *A] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aTop, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, *E, B, D, *A" ), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test move down algorithm.
+*/
+void test_HYDROGUI_ZLevelsModel::testMoveDown()
+{
+ HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ZLevelsModel::OpType aDown = HYDROGUI_ZLevelsModel::Down;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ *E, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 4 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ D, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 3 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 4. [ *A, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 5. [ *A ] X 6 times / ALL OBJECTS
+ aModel->move( QList<int>() << 0, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *A, *C, D, *E, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 1, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *A, D, *E, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 2, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *A, *E, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 3, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, *A, F" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
+ aModel->move( QList<int>() << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
+
+ // 6. [ *E, *F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 3 << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *A, *E, F" ), GetObjects( aModel ) );
+
+ // 7. [ B, D, *E ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2 << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*C, B, *A, D, F, *E" ), GetObjects( aModel ) );
+
+ // 8. [ *C, B, *A, D, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, *C, B, *A, D, F" ), GetObjects( aModel ) );
+
+ // 9. [ *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, B, *A, *C, D, F" ), GetObjects( aModel ) );
+
+ // 10. [ *E, *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 0 << 2, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
+
+ // 11. [ *E, *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 2 << 3, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
+
+ // 12. [ *C, *E, *A ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3, aDown, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F" ), GetObjects( aModel ) );
+
+ // 13. [] / ALL OBJECTS
+ aModel->move( QList<int>(), aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F"), GetObjects( aModel ) );
+
+ // 14. [ B, *C, *E, *A, D, F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aDown, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, *E, *A, D, F"), GetObjects( aModel ) );
+
+ delete aModel;
+}
+
+/**
+ Test move on bottom algorithm.
+*/
+void test_HYDROGUI_ZLevelsModel::testMoveOnBottom()
+{
+ HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+ const HYDROGUI_ZLevelsModel::OpType aBottom = HYDROGUI_ZLevelsModel::Bottom;
+
+ // 0. Check the initial state
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 1. [ F ] / ALL OBJECTS
+ aModel->move( QList<int>() << 5, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 2. [ F ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 5, aBottom, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ // 3. [ *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, *C, D, *E, F, *A" ), GetObjects( aModel ) );
+
+ // 4. [ *C ] / VISIBLE OBJECTS
+ aModel->move( QList<int>() << 1, aBottom, true );
+ CPPUNIT_ASSERT_EQUAL( std::string( "B, D, *E, F, *A, *C" ), GetObjects( aModel ) );
+
+ // 5. [ B, D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, *C, B, D" ), GetObjects( aModel ) );
+
+ // 6. [ *C, *D ] / ALL OBJECTS
+ aModel->move( QList<int>() << 3 << 5, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "*E, F, *A, B, *C, D" ), GetObjects( aModel ) );
+
+ // 7. [ *E, *A, *C ] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 2 << 4, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, B, D, *E, *A, *C" ), GetObjects( aModel ) );
+
+ // 8. [ B, D, *E, *A ] / ALL OBJECTS
+ aModel->move( QList<int>() << 1 << 2 << 3 << 4 , aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
+
+ // 9. [] / ALL OBJECTS
+ aModel->move( QList<int>(), aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
+
+ // 10. [F, *C, B, D, *E, *A] / ALL OBJECTS
+ aModel->move( QList<int>() << 0 << 1 << 2 << 3 << 4 << 5, aBottom, false );
+ CPPUNIT_ASSERT_EQUAL( std::string( "F, *C, B, D, *E, *A" ), GetObjects( aModel ) );
+
delete aModel;
}