Changeset View
Changeset View
Standalone View
Standalone View
autotests/kurlnavigatortest.cpp
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Line(s) | 213 | { | |||
---|---|---|---|---|---|
217 | m_navigator->setLocationUrl(QUrl()); | 217 | m_navigator->setLocationUrl(QUrl()); | ||
218 | m_navigator->setUrlEditable(true); | 218 | m_navigator->setUrlEditable(true); | ||
219 | m_navigator->editor()->setCurrentText(input); | 219 | m_navigator->editor()->setCurrentText(input); | ||
220 | QCOMPARE(m_navigator->uncommittedUrl(), url); | 220 | QCOMPARE(m_navigator->uncommittedUrl(), url); | ||
221 | QTest::keyClick(m_navigator->editor(), Qt::Key_Enter); | 221 | QTest::keyClick(m_navigator->editor(), Qt::Key_Enter); | ||
222 | QCOMPARE(m_navigator->locationUrl(), url); | 222 | QCOMPARE(m_navigator->locationUrl(), url); | ||
223 | } | 223 | } | ||
224 | 224 | | |||
225 | #if KIOFILEWIDGETS_BUILD_DEPRECATED_SINCE(4, 5) | ||||
225 | void KUrlNavigatorTest::testButtonUrl_data() | 226 | void KUrlNavigatorTest::testButtonUrl_data() | ||
226 | { | 227 | { | ||
227 | QTest::addColumn<QUrl>("locationUrl"); | 228 | QTest::addColumn<QUrl>("locationUrl"); | ||
228 | QTest::addColumn<int>("buttonIndex"); | 229 | QTest::addColumn<int>("buttonIndex"); | ||
229 | QTest::addColumn<QUrl>("expectedButtonUrl"); | 230 | QTest::addColumn<QUrl>("expectedButtonUrl"); | ||
230 | 231 | | |||
231 | QTest::newRow("localPathButtonIndex3") << QUrl::fromLocalFile(QStringLiteral("/home/foo")) << 3 << QUrl::fromLocalFile(QStringLiteral("/home/foo")); // out of range | 232 | QTest::newRow("localPathButtonIndex3") << QUrl::fromLocalFile(QStringLiteral("/home/foo")) << 3 << QUrl::fromLocalFile(QStringLiteral("/home/foo")); // out of range | ||
232 | QTest::newRow("localPathButtonIndex2") << QUrl::fromLocalFile(QStringLiteral("/home/foo")) << 2 << QUrl::fromLocalFile(QStringLiteral("/home/foo")); | 233 | QTest::newRow("localPathButtonIndex2") << QUrl::fromLocalFile(QStringLiteral("/home/foo")) << 2 << QUrl::fromLocalFile(QStringLiteral("/home/foo")); | ||
Show All 20 Lines | 248 | { | |||
253 | m_navigator->setLocationUrl(locationUrl); | 254 | m_navigator->setLocationUrl(locationUrl); | ||
254 | 255 | | |||
255 | // WHEN | 256 | // WHEN | ||
256 | const QUrl buttonUrl = m_navigator->url(buttonIndex); | 257 | const QUrl buttonUrl = m_navigator->url(buttonIndex); | ||
257 | 258 | | |||
258 | // THEN | 259 | // THEN | ||
259 | QCOMPARE(buttonUrl, expectedButtonUrl); | 260 | QCOMPARE(buttonUrl, expectedButtonUrl); | ||
260 | } | 261 | } | ||
262 | #endif | ||||
261 | 263 | | |||
262 | void KUrlNavigatorTest::testButtonText() | 264 | void KUrlNavigatorTest::testButtonText() | ||
263 | { | 265 | { | ||
264 | KFilePlacesModel model; | 266 | KFilePlacesModel model; | ||
265 | const QUrl url = QUrl::fromLocalFile(QDir::currentPath()); | 267 | const QUrl url = QUrl::fromLocalFile(QDir::currentPath()); | ||
266 | model.addPlace("&Here", url); | 268 | model.addPlace("&Here", url); | ||
267 | KUrlNavigator navigator(&model, url, nullptr); | 269 | KUrlNavigator navigator(&model, url, nullptr); | ||
268 | 270 | | |||
269 | QList<QPushButton *> buttons = navigator.findChildren<QPushButton *>(); | 271 | QList<QPushButton *> buttons = navigator.findChildren<QPushButton *>(); | ||
270 | const auto it = std::find_if(buttons.cbegin(), buttons.cend(), [](QPushButton *button) { | 272 | const auto it = std::find_if(buttons.cbegin(), buttons.cend(), [](QPushButton *button) { | ||
271 | return button->text() == QLatin1String("&Here"); | 273 | return button->text() == QLatin1String("&Here"); | ||
272 | }); | 274 | }); | ||
273 | QVERIFY(it != buttons.cend()); | 275 | QVERIFY(it != buttons.cend()); | ||
274 | QCOMPARE((*it)->property("plainText").toString(), QStringLiteral("Here")); | 276 | QCOMPARE((*it)->property("plainText").toString(), QStringLiteral("Here")); | ||
275 | } | 277 | } | ||
276 | 278 | | |||
277 | void KUrlNavigatorTest::testInitWithRedundantPathSeparators() | 279 | void KUrlNavigatorTest::testInitWithRedundantPathSeparators() | ||
278 | { | 280 | { | ||
279 | KUrlNavigator temp_nav(nullptr, QUrl::fromLocalFile(QStringLiteral("/home/foo///test")), nullptr); | 281 | KUrlNavigator temp_nav(nullptr, QUrl::fromLocalFile(QStringLiteral("/home/foo///test")), nullptr); | ||
280 | 282 | | |||
281 | const QUrl buttonUrl = temp_nav.url(3); | 283 | const QUrl buttonUrl = temp_nav.locationUrl(); | ||
282 | 284 | | |||
283 | QCOMPARE(buttonUrl, QUrl::fromLocalFile(QStringLiteral("/home/foo/test"))); | 285 | QCOMPARE(buttonUrl, QUrl::fromLocalFile(QStringLiteral("/home/foo/test"))); | ||
284 | } | 286 | } |