示例#1
0
        public void TestAddMultipleRowsAndScroll()
        {
            TableViewMock  table = new TableViewMock(320, 15);
            CTableViewCell c1    = new TableViewCellMock1(table.Width, 10);
            CTableViewCell c2    = new TableViewCellMock2(table.Width, 15);
            CTableViewCell c3    = new TableViewCellMock1(table.Width, 10);
            CTableViewCell c4    = new TableViewCellMock2(table.Width, 15);
            CTableViewCell c5    = new TableViewCellMock1(table.Width, 10);
            CTableViewCell c6    = new TableViewCellMock2(table.Width, 15);

            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new CTableViewCell[0]);

            table.DataSource = adapter;
            table.Delegate   = adapter;

            adapter.Add(c1, c2, c3, c4, c5, c6);

            table.ReloadNewData();
            AssertVisibleRows(table, c1, c2);

            table.Scroll(15);
            AssertVisibleRows(table, c2, c3);

            table.Scroll(10);
            AssertVisibleRows(table, c3, c4);

            table.Scroll(15);
            AssertVisibleRows(table, c4, c5);

            table.Scroll(10);
            AssertVisibleRows(table, c5, c6);

            table.Scroll(15);
            AssertVisibleRows(table, c6);

            table.Scroll(-15);
            AssertVisibleRows(table, c5, c6);

            table.Scroll(-10);
            AssertVisibleRows(table, c4, c5);

            table.Scroll(-15);
            AssertVisibleRows(table, c3, c4);

            table.Scroll(-10);
            AssertVisibleRows(table, c2, c3);

            table.Scroll(-15);
            AssertVisibleRows(table, c1, c2);
        }
        public void TestAddMultipleRowsAndScroll()
        {
            TableViewMock table = new TableViewMock(320, 15);
            TableViewCell c1 = new TableViewCellMock1(table.Width, 10);
            TableViewCell c2 = new TableViewCellMock2(table.Width, 15);
            TableViewCell c3 = new TableViewCellMock1(table.Width, 10);
            TableViewCell c4 = new TableViewCellMock2(table.Width, 15);
            TableViewCell c5 = new TableViewCellMock1(table.Width, 10);
            TableViewCell c6 = new TableViewCellMock2(table.Width, 15);

            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new TableViewCell[0]);
            table.DataSource = adapter;
            table.Delegate = adapter;

            adapter.Add(c1, c2, c3, c4, c5, c6);

            table.ReloadNewData();
            AssertVisibleRows(table, c1, c2);

            table.Scroll(15);
            AssertVisibleRows(table, c2, c3);

            table.Scroll(10);
            AssertVisibleRows(table, c3, c4);

            table.Scroll(15);
            AssertVisibleRows(table, c4, c5);

            table.Scroll(10);
            AssertVisibleRows(table, c5, c6);

            table.Scroll(15);
            AssertVisibleRows(table, c6);

            table.Scroll(-15);
            AssertVisibleRows(table, c5, c6);

            table.Scroll(-10);
            AssertVisibleRows(table, c4, c5);

            table.Scroll(-15);
            AssertVisibleRows(table, c3, c4);

            table.Scroll(-10);
            AssertVisibleRows(table, c2, c3);

            table.Scroll(-15);
            AssertVisibleRows(table, c1, c2);
        }
示例#3
0
        public void TestAddItemsScrollLock()
        {
            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new CTableViewCell[0]);

            TableViewMock table = new TableViewMock(320, 30);

            table.DataSource     = adapter;
            table.Delegate       = adapter;
            table.IsScrollLocked = true;
            table.ReloadData();

            adapter.Add(new TableViewCellMock(table.Width, 10));
            table.ReloadNewData();
            AssertVisibleRows(table, 0);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 15));
            table.ReloadNewData();
            AssertVisibleRows(table, 0, 1);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 10));
            table.ReloadNewData();
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(5, table.ScrollPosTop);
            Assert.AreEqual(35, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 15));
            table.ReloadNewData();
            AssertVisibleRows(table, 1, 2, 3);
            Assert.AreEqual(20, table.ScrollPosTop);
            Assert.AreEqual(50, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 10));
            table.ReloadNewData();
            AssertVisibleRows(table, 2, 3, 4);
            Assert.AreEqual(30, table.ScrollPosTop);
            Assert.AreEqual(60, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 15));
            table.ReloadNewData();
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);
        }
        public void TestAddItemsScrollLock()
        {
            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new TableViewCell[0]);

            TableViewMock table = new TableViewMock(320, 30);
            table.DataSource = adapter;
            table.Delegate = adapter;
            table.IsScrollLocked = true;
            table.ReloadData();

            adapter.Add(new TableViewCellMock(table.Width, 10));
            table.ReloadNewData();
            AssertVisibleRows(table, 0);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 15));
            table.ReloadNewData();
            AssertVisibleRows(table, 0, 1);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 10));
            table.ReloadNewData();
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(5, table.ScrollPosTop);
            Assert.AreEqual(35, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 15));
            table.ReloadNewData();
            AssertVisibleRows(table, 1, 2, 3);
            Assert.AreEqual(20, table.ScrollPosTop);
            Assert.AreEqual(50, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 10));
            table.ReloadNewData();
            AssertVisibleRows(table, 2, 3, 4);
            Assert.AreEqual(30, table.ScrollPosTop);
            Assert.AreEqual(60, table.ScrollPosBottom);

            adapter.Add(new TableViewCellMock(table.Width, 15));
            table.ReloadNewData();
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);
        }
        public void TestAddMultipleRows()
        {
            TableViewMock table = new TableViewMock(320, 15);
            TableViewCell a1 = new TableViewCellMock1(table.Width, 10);
            TableViewCell a2 = new TableViewCellMock2(table.Width, 15);
            TableViewCell a3 = new TableViewCellMock3(table.Width, 10);

            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new TableViewCell[] { a1 });

            table.DataSource = adapter;
            table.Delegate = adapter;
            table.ReloadData();

            adapter.Add(a2);
            adapter.Add(a3);
            table.ReloadNewData();

            AssertVisibleRows(table, a1, a2);
        }
示例#6
0
        public void TestAddMultipleRows()
        {
            TableViewMock  table = new TableViewMock(320, 15);
            CTableViewCell a1    = new TableViewCellMock1(table.Width, 10);
            CTableViewCell a2    = new TableViewCellMock2(table.Width, 15);
            CTableViewCell a3    = new TableViewCellMock3(table.Width, 10);

            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new CTableViewCell[] { a1 });

            table.DataSource = adapter;
            table.Delegate   = adapter;
            table.ReloadData();

            adapter.Add(a2);
            adapter.Add(a3);
            table.ReloadNewData();

            AssertVisibleRows(table, a1, a2);
        }
示例#7
0
        public void TestAddTwoRows()
        {
            TableViewMock  table = new TableViewMock(320, 15);
            CTableViewCell a1    = new TableViewCellMock1(table.Width, 10);
            CTableViewCell a2    = new TableViewCellMock2(table.Width, 15);

            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new CTableViewCell[] { a1 });

            table.DataSource = adapter;
            table.Delegate   = adapter;
            table.ReloadData();

            adapter.Add(a2);
            table.ReloadNewData();

            CTableViewCell b1 = table.FirstVisibleCell;
            CTableViewCell b2 = b1.NextCell;

            Assert.AreSame(a1, b1);
            Assert.AreSame(a2, b2);
            AssertVisibleRows(table, 0, 1);
        }
        public void TestAddTwoRows()
        {
            TableViewMock table = new TableViewMock(320, 15);
            TableViewCell a1 = new TableViewCellMock1(table.Width, 10);
            TableViewCell a2 = new TableViewCellMock2(table.Width, 15);

            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new TableViewCell[] { a1 });

            table.DataSource = adapter;
            table.Delegate = adapter;
            table.ReloadData();

            adapter.Add(a2);
            table.ReloadNewData();

            TableViewCell b1 = table.FirstVisibleCell;
            TableViewCell b2 = b1.NextCell;

            Assert.AreSame(a1, b1);
            Assert.AreSame(a2, b2);
            AssertVisibleRows(table, 0, 1);
        }
示例#9
0
        public void TestItemsScroll()
        {
            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new CTableViewCell[0]);

            adapter.Add(new TableViewCellMock(320, 10));
            adapter.Add(new TableViewCellMock(320, 15));
            adapter.Add(new TableViewCellMock(320, 10));
            adapter.Add(new TableViewCellMock(320, 15));
            adapter.Add(new TableViewCellMock(320, 10));
            adapter.Add(new TableViewCellMock(320, 15));

            TableViewMock table = new TableViewMock(320, 30);

            table.DataSource = adapter;
            table.Delegate   = adapter;
            table.ReloadData();

            // scroll forward

            table.ScrollUntilRowVisible(0);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(1);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(2);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(5, table.ScrollPosTop);
            Assert.AreEqual(35, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(3);
            AssertVisibleRows(table, 1, 2, 3);
            Assert.AreEqual(20, table.ScrollPosTop);
            Assert.AreEqual(50, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(4);
            AssertVisibleRows(table, 2, 3, 4);
            Assert.AreEqual(30, table.ScrollPosTop);
            Assert.AreEqual(60, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(5);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);

            // scroll back

            table.ScrollUntilRowVisible(5);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(4);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(3);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(35, table.ScrollPosTop);
            Assert.AreEqual(65, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(2);
            AssertVisibleRows(table, 2, 3, 4);
            Assert.AreEqual(25, table.ScrollPosTop);
            Assert.AreEqual(55, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(1);
            AssertVisibleRows(table, 1, 2, 3);
            Assert.AreEqual(10, table.ScrollPosTop);
            Assert.AreEqual(40, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(0);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);
        }
        public void TestItemsScroll()
        {
            TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new TableViewCell[0]);
            adapter.Add(new TableViewCellMock(320, 10));
            adapter.Add(new TableViewCellMock(320, 15));
            adapter.Add(new TableViewCellMock(320, 10));
            adapter.Add(new TableViewCellMock(320, 15));
            adapter.Add(new TableViewCellMock(320, 10));
            adapter.Add(new TableViewCellMock(320, 15));

            TableViewMock table = new TableViewMock(320, 30);
            table.DataSource = adapter;
            table.Delegate = adapter;
            table.ReloadData();

            // scroll forward

            table.ScrollUntilRowVisible(0);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(1);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(2);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(5, table.ScrollPosTop);
            Assert.AreEqual(35, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(3);
            AssertVisibleRows(table, 1, 2, 3);
            Assert.AreEqual(20, table.ScrollPosTop);
            Assert.AreEqual(50, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(4);
            AssertVisibleRows(table, 2, 3, 4);
            Assert.AreEqual(30, table.ScrollPosTop);
            Assert.AreEqual(60, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(5);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);

            // scroll back

            table.ScrollUntilRowVisible(5);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(4);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(45, table.ScrollPosTop);
            Assert.AreEqual(75, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(3);
            AssertVisibleRows(table, 3, 4, 5);
            Assert.AreEqual(35, table.ScrollPosTop);
            Assert.AreEqual(65, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(2);
            AssertVisibleRows(table, 2, 3, 4);
            Assert.AreEqual(25, table.ScrollPosTop);
            Assert.AreEqual(55, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(1);
            AssertVisibleRows(table, 1, 2, 3);
            Assert.AreEqual(10, table.ScrollPosTop);
            Assert.AreEqual(40, table.ScrollPosBottom);

            table.ScrollUntilRowVisible(0);
            AssertVisibleRows(table, 0, 1, 2);
            Assert.AreEqual(0, table.ScrollPosTop);
            Assert.AreEqual(30, table.ScrollPosBottom);
        }