Changeset View
Changeset View
Standalone View
Standalone View
runners/bookmarks/tests/testchromebookmarks.cpp
Show All 16 Lines | |||||
17 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "testchromebookmarks.h" | 21 | #include "testchromebookmarks.h" | ||
22 | #include <QTest> | 22 | #include <QTest> | ||
23 | #include <QDir> | 23 | #include <QDir> | ||
24 | #include "browsers/chrome.h" | 24 | #include "browsers/chrome.h" | ||
25 | #include "browsers/chromefindprofile.h" | 25 | #include "browsers/chromeprofile.h" | ||
26 | #include "favicon.h" | 26 | #include "favicon.h" | ||
27 | 27 | | |||
28 | using namespace Plasma; | 28 | using namespace Plasma; | ||
29 | 29 | | |||
30 | void TestChromeBookmarks::initTestCase() | 30 | void TestChromeBookmarks::initTestCase() | ||
31 | { | 31 | { | ||
32 | m_findBookmarksInCurrentDirectory.reset(new FakeFindProfile(QList<Profile>({Profile("chrome-config-home/Chrome-Bookmarks-Sample.json", "Sample", new FallbackFavicon())}))); | | |||
33 | } | 32 | } | ||
34 | 33 | | |||
35 | void TestChromeBookmarks::bookmarkFinderShouldFindEachProfileDirectory() | 34 | /*void TestChromeBookmarks::bookmarkFinderShouldFindEachProfileDirectory() | ||
36 | { | 35 | { | ||
37 | FindChromeProfile findChrome("chromium", "./chrome-config-home"); | 36 | QString profileTemplate = QString("%1/.config/%2/%3/Bookmarks"); | ||
38 | QString profileTemplate = QString("./chrome-config-home/.config/%1/%2/Bookmarks"); | 37 | QList<ProfileBookmarks*> profiles = ProfileBookmarks::findAllProfiles("chromium"); | ||
39 | | ||||
40 | QList<Profile> profiles = findChrome.find(); | | |||
41 | QCOMPARE(profiles.size(), 2); | 38 | QCOMPARE(profiles.size(), 2); | ||
42 | QCOMPARE(profiles[0].path(), profileTemplate.arg("chromium").arg("Default")); | 39 | QCOMPARE(profiles[0]->path(), profileTemplate.arg(QDir::homePath(), "chromium", "Default")); | ||
43 | QCOMPARE(profiles[1].path(), profileTemplate.arg("chromium").arg("Profile 1")); | 40 | QCOMPARE(profiles[1]->path(), profileTemplate.arg(QDir::homePath(), "chromium", "Profile 1")); | ||
44 | } | | |||
45 | | ||||
46 | void TestChromeBookmarks::bookmarkFinderShouldReportNoProfilesOnErrors() | | |||
47 | { | | |||
48 | FindChromeProfile findChrome("chromium", "./no-config-directory"); | | |||
49 | | ||||
50 | QList<Profile> profiles = findChrome.find(); | | |||
51 | QCOMPARE(profiles.size(), 0); | | |||
52 | } | 41 | } | ||
53 | 42 | | |||
54 | | ||||
55 | void TestChromeBookmarks::itShouldFindNothingWhenPrepareIsNotCalled() | 43 | void TestChromeBookmarks::itShouldFindNothingWhenPrepareIsNotCalled() | ||
56 | { | 44 | { | ||
57 | Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.data(), this); | 45 | Chrome *chrome = new Chrome("chromium", this); | ||
58 | QCOMPARE(chrome->match("any", true).size(), 0); | 46 | QCOMPARE(chrome->match("any", true).size(), 0); | ||
59 | } | 47 | } | ||
60 | 48 | | |||
61 | void TestChromeBookmarks::itShouldGracefullyExitWhenFileIsNotFound() | 49 | void TestChromeBookmarks::itShouldGracefullyExitWhenFileIsNotFound() | ||
62 | { | 50 | { | ||
63 | FakeFindProfile finder(QList<Profile>() << Profile("FileNotExisting.json", QString(), nullptr)); | 51 | FakeFindProfile finder(QList<Profile>() << Profile("FileNotExisting.json", QString(), nullptr)); | ||
64 | Chrome *chrome = new Chrome(&finder, this); | 52 | Chrome *chrome = new Chrome(&finder, this); | ||
65 | chrome->prepare(); | 53 | chrome->prepare(); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 98 | { | |||
116 | QList<BookmarkMatch> matches = chrome->match("any", true); | 104 | QList<BookmarkMatch> matches = chrome->match("any", true); | ||
117 | QCOMPARE(matches.size(), 4); | 105 | QCOMPARE(matches.size(), 4); | ||
118 | verifyMatch(matches[0], "some bookmark in bookmark bar", "https://somehost.com/", 0.18, QueryMatch::PossibleMatch); | 106 | verifyMatch(matches[0], "some bookmark in bookmark bar", "https://somehost.com/", 0.18, QueryMatch::PossibleMatch); | ||
119 | verifyMatch(matches[1], "bookmark in other bookmarks", "https://otherbookmarks.com/", 0.18, QueryMatch::PossibleMatch); | 107 | verifyMatch(matches[1], "bookmark in other bookmarks", "https://otherbookmarks.com/", 0.18, QueryMatch::PossibleMatch); | ||
120 | verifyMatch(matches[2], "bookmark in somefolder", "https://somefolder.com/", 0.18, QueryMatch::PossibleMatch); | 108 | verifyMatch(matches[2], "bookmark in somefolder", "https://somefolder.com/", 0.18, QueryMatch::PossibleMatch); | ||
121 | verifyMatch(matches[3], "bookmark in secondProfile", "https://secondprofile.com/", 0.18, QueryMatch::PossibleMatch); | 109 | verifyMatch(matches[3], "bookmark in secondProfile", "https://secondprofile.com/", 0.18, QueryMatch::PossibleMatch); | ||
122 | } | 110 | } | ||
123 | 111 | | |||
124 | 112 | */ | |||
125 | QTEST_MAIN(TestChromeBookmarks); | 113 | QTEST_MAIN(TestChromeBookmarks); |