Better organize bookmarks runner tests

wilder-5.22
Alexander Lohnau 5 years ago
parent a8ec95411a
commit de9588fc64
  1. 2
      runners/bookmarks/CMakeLists.txt
  2. 7
      runners/bookmarks/autotests/CMakeLists.txt
  3. 0
      runners/bookmarks/autotests/chrome/chrome-config-home/.config/chromium/Local State
  4. 0
      runners/bookmarks/autotests/chrome/chrome-config-home/Chrome-Bookmarks-Sample.json
  5. 0
      runners/bookmarks/autotests/chrome/chrome-config-home/Chrome-Bookmarks-SecondProfile.json
  6. 11
      runners/bookmarks/autotests/chrome/testchromebookmarks.cpp
  7. 1
      runners/bookmarks/autotests/chrome/testchromebookmarks.h
  8. 8
      runners/bookmarks/tests/CMakeLists.txt

@ -62,5 +62,5 @@ install(TARGETS krunner_bookmarksrunner DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf
# Currently tests include only chrome, so no need to get include them if json is not found
if(BUILD_TESTING)
add_subdirectory(tests)
add_subdirectory(autotests)
endif()

@ -0,0 +1,7 @@
include(ECMAddTests)
ecm_add_test(chrome/testchromebookmarks.cpp TEST_NAME testChromeBookmarks
LINK_LIBRARIES Qt::Test krunner_bookmarks_test
)
file(COPY chrome/chrome-config-home DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/chrome/)

@ -29,14 +29,15 @@ using namespace Plasma;
void TestChromeBookmarks::initTestCase()
{
m_configHome = QFINDTESTDATA("chrome-config-home");
m_findBookmarksInCurrentDirectory.reset(
new FakeFindProfile(QList<Profile>({Profile("chrome-config-home/Chrome-Bookmarks-Sample.json", "Sample", new FallbackFavicon())})));
new FakeFindProfile(QList<Profile>({Profile(m_configHome + "/Chrome-Bookmarks-Sample.json", "Sample", new FallbackFavicon())})));
}
void TestChromeBookmarks::bookmarkFinderShouldFindEachProfileDirectory()
{
FindChromeProfile findChrome("chromium", "./chrome-config-home");
QString profileTemplate = QStringLiteral("./chrome-config-home/.config/%1/%2/Bookmarks");
FindChromeProfile findChrome("chromium", m_configHome);
QString profileTemplate = m_configHome + "/.config/%1/%2/Bookmarks";
QList<Profile> profiles = findChrome.find();
QCOMPARE(profiles.size(), 2);
@ -107,8 +108,8 @@ void TestChromeBookmarks::itShouldClearResultAfterCallingTeardown()
void TestChromeBookmarks::itShouldFindBookmarksFromAllProfiles()
{
FakeFindProfile findBookmarksFromAllProfiles(
QList<Profile>() << Profile("chrome-config-home/Chrome-Bookmarks-Sample.json", "Sample", new FallbackFavicon(this))
<< Profile("chrome-config-home/Chrome-Bookmarks-SecondProfile.json", "SecondProfile", new FallbackFavicon(this)));
QList<Profile>() << Profile(m_configHome + "/Chrome-Bookmarks-Sample.json", "Sample", new FallbackFavicon(this))
<< Profile(m_configHome + "/Chrome-Bookmarks-SecondProfile.json", "SecondProfile", new FallbackFavicon(this)));
Chrome *chrome = new Chrome(&findBookmarksFromAllProfiles, this);
chrome->prepare();
QList<BookmarkMatch> matches = chrome->match("any", true);

@ -61,6 +61,7 @@ private Q_SLOTS:
private:
QScopedPointer<FakeFindProfile> m_findBookmarksInCurrentDirectory;
QString m_configHome;
};
#endif // TESTCHROMEBOOKMARKS_H

@ -1,8 +0,0 @@
include(ECMAddTests)
ecm_add_test(testchromebookmarks.cpp TEST_NAME testChromeBookmarks
LINK_LIBRARIES Qt::Test krunner_bookmarks_test
)
file(COPY chrome-config-home DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
Loading…
Cancel
Save