1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

WebTab: Fix updating isCurrentTab in attach

This commit is contained in:
David Rosca 2018-02-02 10:53:31 +01:00
parent 16c7af63b6
commit af95dd14e2
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 29 additions and 1 deletions

View File

@ -113,12 +113,39 @@ void TabModelTest::dataTest()
QCOMPARE(model.index(0, 0).data(Qt::DecorationRole).value<QIcon>().pixmap(16), tab0->icon().pixmap(16)); QCOMPARE(model.index(0, 0).data(Qt::DecorationRole).value<QIcon>().pixmap(16), tab0->icon().pixmap(16));
QCOMPARE(model.index(0, 0).data(TabModel::PinnedRole).toBool(), tab0->isPinned()); QCOMPARE(model.index(0, 0).data(TabModel::PinnedRole).toBool(), tab0->isPinned());
QCOMPARE(model.index(0, 0).data(TabModel::RestoredRole).toBool(), tab0->isRestored()); QCOMPARE(model.index(0, 0).data(TabModel::RestoredRole).toBool(), tab0->isRestored());
QCOMPARE(model.index(0, 0).data(TabModel::CurrentTabRole).toBool(), true);
w->tabWidget()->addView(QUrl("http://test.com")); w->tabWidget()->addView(QUrl("http://test.com"));
QTest::qWait(10); QTest::qWait(10);
delete w; delete w;
} }
void TabModelTest::pinTabTest()
{
BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow);
TabModel model(w);
ModelTest modelTest(&model);
w->tabWidget()->addView(QUrl("http://test.com"));
QTRY_COMPARE(model.rowCount(), 2);
WebTab *tab0 = w->weView(0)->webTab();
WebTab *tab1 = w->weView(1)->webTab();
QCOMPARE(model.data(model.index(0, 0), TabModel::WebTabRole).value<WebTab*>(), tab0);
QCOMPARE(model.data(model.index(1, 0), TabModel::WebTabRole).value<WebTab*>(), tab1);
tab1->togglePinned();
QCOMPARE(model.data(model.index(0, 0), TabModel::WebTabRole).value<WebTab*>(), tab1);
QCOMPARE(model.data(model.index(1, 0), TabModel::WebTabRole).value<WebTab*>(), tab0);
QTest::qWait(10);
delete w;
}
void TabModelTest::treeModelTest() void TabModelTest::treeModelTest()
{ {
BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow); BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow);

View File

@ -29,6 +29,7 @@ private slots:
void basicTest(); void basicTest();
void dataTest(); void dataTest();
void pinTabTest();
void treeModelTest(); void treeModelTest();
void resetTreeModelTest(); void resetTreeModelTest();
}; };

View File

@ -339,7 +339,7 @@ void WebTab::attach(BrowserWindow* window)
} }
}; };
currentTabChanged(m_tabBar->currentIndex()); currentChanged(m_tabBar->currentIndex());
connect(m_tabBar, &TabBar::currentChanged, this, currentChanged); connect(m_tabBar, &TabBar::currentChanged, this, currentChanged);
} }