Merge lp:~townsend/libertine-scope/release-1.3 into lp:libertine-scope/release

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 42
Merged at revision: 42
Proposed branch: lp:~townsend/libertine-scope/release-1.3
Merge into: lp:libertine-scope/release
Diff against target: 2064 lines (+1116/-263)
42 files modified
.bzrignore (+1/-0)
CMakeLists.txt (+11/-8)
data/CMakeLists.txt (+6/-9)
data/blacklist (+11/-0)
data/libertine-scope-settings.ini.in (+0/-24)
debian/changelog (+23/-0)
libertine-scope.apparmor (+1/-1)
libertine-scope/CMakeLists.txt (+4/-1)
libertine-scope/action.cpp (+66/-0)
libertine-scope/action.h (+45/-0)
libertine-scope/blacklist.cpp (+78/-0)
libertine-scope/blacklist.h (+36/-0)
libertine-scope/config.h.in (+26/-0)
libertine-scope/hidden_apps.cpp (+92/-0)
libertine-scope/hidden_apps.h (+38/-0)
libertine-scope/preview.cpp (+20/-0)
libertine-scope/preview.h (+0/-2)
libertine-scope/query.cpp (+192/-34)
libertine-scope/query.h (+26/-18)
libertine-scope/scope.cpp (+14/-37)
po/en_AU.po (+4/-3)
po/en_GB.po (+4/-3)
po/es.po (+9/-5)
po/fi.po (+4/-3)
po/fr.po (+4/-3)
po/gl.po (+8/-3)
po/libertine-scope.pot (+23/-1)
po/ms.po (+4/-3)
po/pt.po (+4/-3)
po/uk.po (+4/-3)
tests/CMakeLists.txt (+24/-21)
tests/TypedScopeFixture.h (+1/-0)
tests/data/blacklist (+9/-0)
tests/data/hidden (+1/-0)
tests/fake_container.cpp (+1/-2)
tests/fake_container_json.h (+2/-2)
tests/fake_libertine.cpp (+0/-6)
tests/fake_libertine.h (+2/-2)
tests/test_blacklist.cpp (+65/-0)
tests/test_hidden_apps.cpp (+107/-0)
tests/test_preview.cpp (+2/-1)
tests/test_query.cpp (+144/-65)
To merge this branch: bzr merge lp:~townsend/libertine-scope/release-1.3
Reviewer Review Type Date Requested Status
Larry Price Approve
Review via email: mp+297631@code.launchpad.net

Commit message

* Use wildcard matching for allowing reading any puritine click package paths that have the name "puritine" anywhere in the Click package name. (LP: #1590453)
* Replace the scope settings approach to suppress display of apps with a scope filter based approach. This provides a blacklist file for permanent suppression and filters for user suppression.
* Provide a "Hidden X Apps" department for a place to store the apps hidden in the main scope view, so they can be unhidden later if desired.
* Hide 'Help' by default for all containers. (LP: #1591511)
* Removed Settings. (LP: #1591494)
* Refactor Query class for consistent style and extract some functionality to helper classes.
* Show a message when no apps are available due to filters or no apps installed. (LP: #1589699)

To post a comment you must log in.
Revision history for this message
Larry Price (larryprice) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2016-02-29 18:49:55 +0000
+++ .bzrignore 2016-06-16 14:35:35 +0000
@@ -1,2 +1,3 @@
1po/POTFILES.in1po/POTFILES.in
2po/Makefile.in.in2po/Makefile.in.in
3config.h
34
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-06-01 20:28:54 +0000
+++ CMakeLists.txt 2016-06-16 14:35:35 +0000
@@ -1,6 +1,6 @@
1cmake_minimum_required(VERSION 3.0)1cmake_minimum_required(VERSION 3.0)
2project(libertine-scope2project(libertine-scope
3 VERSION 1.23 VERSION 1.3
4 LANGUAGES CXX)4 LANGUAGES CXX)
55
6# We require at least g++ 4.9, to avoid ABI breakage with earlier versions.6# We require at least g++ 4.9, to avoid ABI breakage with earlier versions.
@@ -46,7 +46,10 @@
46set(APP ${PROJECT})46set(APP ${PROJECT})
4747
48# Important project paths48# Important project paths
49# Use this SCOPE_INSTALL_DIR when building the debian
49set(SCOPE_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/libertine-scope/)50set(SCOPE_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/libertine-scope/)
51# USE this when building the click
52#set(SCOPE_INSTALL_DIR "/libertine-scope")
50set(SCOPE_NAME "libertine-scope")53set(SCOPE_NAME "libertine-scope")
51set(GETTEXT_PACKAGE "${SCOPE_NAME}")54set(GETTEXT_PACKAGE "${SCOPE_NAME}")
5255
@@ -63,10 +66,12 @@
6366
64# Configure and install the click manifest and apparmor files67# Configure and install the click manifest and apparmor files
65configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)68configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
66install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json69install(FILES
67 DESTINATION ${SCOPE_INSTALL_DIR})70 ${CMAKE_CURRENT_BINARY_DIR}/manifest.json
68install(FILES "libertine-scope.apparmor"71 "libertine-scope.apparmor"
69 DESTINATION ${SCOPE_INSTALL_DIR})72 DESTINATION ${SCOPE_INSTALL_DIR})
73#Use this DESTINATION when building click
74# DESTINATION "/")
7075
71# Add our main directories76# Add our main directories
72add_subdirectory(libertine-scope)77add_subdirectory(libertine-scope)
@@ -76,9 +81,7 @@
76# Set up the tests81# Set up the tests
77enable_testing()82enable_testing()
78add_subdirectory(tests)83add_subdirectory(tests)
79add_custom_target(check84add_custom_target(check ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure)
80 ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure
81)
8285
83set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})86set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
84add_custom_target(dist87add_custom_target(dist
8588
=== modified file 'data/CMakeLists.txt'
--- data/CMakeLists.txt 2016-06-02 16:56:29 +0000
+++ data/CMakeLists.txt 2016-06-16 14:35:35 +0000
@@ -1,4 +1,3 @@
1
2# Put the ini files in the build directory next to the scope1# Put the ini files in the build directory next to the scope
3# .so file so that the test tools can find them.2# .so file so that the test tools can find them.
4intltool_merge_translations(3intltool_merge_translations(
@@ -7,18 +6,11 @@
7 ALL6 ALL
8 UTF87 UTF8
9)8)
10intltool_merge_translations(
11 "libertine-scope-settings.ini.in"
12 "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}-settings.ini"
13 ALL
14 UTF8
15)
169
17# Install the scope ini files10# Install the scope ini files
18install(11install(
19 FILES12 FILES
20 "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}.ini"13 "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}.ini"
21 "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}-settings.ini"
22 DESTINATION14 DESTINATION
23 ${SCOPE_INSTALL_DIR}15 ${SCOPE_INSTALL_DIR}
24)16)
@@ -31,4 +23,9 @@
31 ${SCOPE_INSTALL_DIR}23 ${SCOPE_INSTALL_DIR}
32)24)
3325
3426install(
27 FILES
28 "blacklist"
29 DESTINATION
30 ${SCOPE_INSTALL_DIR}
31)
3532
=== added file 'data/blacklist'
--- data/blacklist 1970-01-01 00:00:00 +0000
+++ data/blacklist 2016-06-16 14:35:35 +0000
@@ -0,0 +1,11 @@
1# containerID/desktop file name (without .desktop extension)
2# use containerID "all" to blacklist app from all containers
3# examples:
4all/mb-panel-manager
5all/openjdk-7-java
6all/openjdk-7-policytool
7all/debian-uxterm
8all/yelp
9# include apps per container that are blacklisted for "all" by prepending "whitelist/"
10#whitelist/testc/yelp
11#whitelist/testc/mb-panel-manager
012
=== removed file 'data/libertine-scope-settings.ini.in'
--- data/libertine-scope-settings.ini.in 2016-04-21 16:25:00 +0000
+++ data/libertine-scope-settings.ini.in 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1[blacklist]
2type = string
3_displayName = Excluded Apps
4defaultValue = Panel Manager;OpenJDK Java 7 Policy Tool;OpenJDK Java 8 Policy Tool;
5
6# Below are some example settings. You can access your scope's
7# settings by calling settings() from the Query::run() method.
8# E.g. auto location = settings().at("location").get_string();
9
10#[location]
11#type = string
12#defaultValue = London,uk
13#_displayName = Default Location
14
15#[units]
16#type = list
17#_displayName = Temperature Units
18#_displayValues = Metric;Imperial
19#defaultValue = 0
20
21#[forecast]
22#type = boolean
23#defaultValue = true
24#_displayName = Show Forecast
250
=== modified file 'debian/changelog'
--- debian/changelog 2016-06-02 18:45:10 +0000
+++ debian/changelog 2016-06-16 14:35:35 +0000
@@ -1,3 +1,26 @@
1libertine-scope (1.3-0ubuntu1) UNRELEASED; urgency=medium
2
3 [ Chris Townsend ]
4 * Use wildcard matching for allowing reading any puritine click package paths
5 that have the name "puritine" anywhere in the Click package name. (LP: #1590453)
6
7 [ Kyle Nitzsche ]
8 * Replace the scope settings approach to suppress display of apps with a scope
9 filter based approach. This provides a blacklist file for permanent suppression
10 and filters for user suppression.
11 * Provide a "Hidden X Apps" department for a place to store the apps hidden in
12 the main scope view, so they can be unhidden later if desired.
13 * Hide 'Help' by default for all containers. (LP: #1591511)
14 * Removed Settings. (LP: #1591494)
15
16 [ Larry Price ]
17 * Refactor Query class for consistent style and extract some functionality to
18 helper classes.
19 * Show a message when no apps are available due to filters or no apps installed.
20 (LP: #1589699)
21
22 -- Chris Townsend <christopher.townsend@canonical.com> Thu, 16 Jun 2016 08:47:40 -0400
23
1libertine-scope (1.2+16.10.20160602.1-0ubuntu1) yakkety; urgency=medium24libertine-scope (1.2+16.10.20160602.1-0ubuntu1) yakkety; urgency=medium
225
3 [ Chris Townsend ]26 [ Chris Townsend ]
427
=== modified file 'libertine-scope.apparmor'
--- libertine-scope.apparmor 2016-06-01 16:09:43 +0000
+++ libertine-scope.apparmor 2016-06-16 14:35:35 +0000
@@ -5,7 +5,7 @@
5 "read_path": [5 "read_path": [
6 "@{HOME}/.local/share/libertine/",6 "@{HOME}/.local/share/libertine/",
7 "@{HOME}/.cache/libertine-container/",7 "@{HOME}/.cache/libertine-container/",
8 "@{CLICK_DIR}/com.ubuntu.puritine/"8 "@{CLICK_DIR}/*puritine*/"
9 ],9 ],
10 "write_path": [10 "write_path": [
11 "/{dev,run}/shm/lttng-ust-wait-5*"11 "/{dev,run}/shm/lttng-ust-wait-5*"
1212
=== modified file 'libertine-scope/CMakeLists.txt'
--- libertine-scope/CMakeLists.txt 2016-05-20 20:55:47 +0000
+++ libertine-scope/CMakeLists.txt 2016-06-16 14:35:35 +0000
@@ -24,12 +24,15 @@
24 ${URL_DISPATCHER_LIBRARIES}24 ${URL_DISPATCHER_LIBRARIES}
25)25)
2626
27configure_file(
28 "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
29 "${CMAKE_CURRENT_SOURCE_DIR}/config.h"
30)
2731
28set_target_properties(scope32set_target_properties(scope
29 PROPERTIES33 PROPERTIES
30 OUTPUT_NAME "${PACKAGE_NAME}_${SCOPE_NAME}"34 OUTPUT_NAME "${PACKAGE_NAME}_${SCOPE_NAME}"
31)35)
32
33install(TARGETS scope36install(TARGETS scope
34 LIBRARY DESTINATION ${SCOPE_INSTALL_DIR}37 LIBRARY DESTINATION ${SCOPE_INSTALL_DIR}
35)38)
3639
=== added file 'libertine-scope/action.cpp'
--- libertine-scope/action.cpp 1970-01-01 00:00:00 +0000
+++ libertine-scope/action.cpp 2016-06-16 14:35:35 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 * * Authored by:
16 * Kyle Nitzsche <kyle.nitzsche@canonical.com>
17 */
18
19#include "libertine-scope/action.h"
20#include "libertine-scope/config.h"
21#include "libertine-scope/hidden_apps.h"
22#include <unity/scopes/ActivationResponse.h>
23#include <unity/scopes/CannedQuery.h>
24#include <url-dispatcher.h>
25#include <QString>
26#include <QFile>
27#include <QTextStream>
28
29namespace usc = unity::scopes;
30
31
32Action::
33Action(usc::Result const& result,
34 usc::ActionMetadata const& metadata,
35 std::string const& action_id,
36 std::shared_ptr<HiddenApps> hidden)
37 : usc::ActivationQueryBase(result, metadata),
38 action_id_(action_id),
39 hidden_(hidden)
40{
41}
42
43usc::ActivationResponse
44Action::activate()
45{
46 if (action_id_ == "open")
47 {
48 url_dispatch_send(result().uri().c_str() , NULL, NULL);
49 return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled);
50 }
51 else if (action_id_ == "hide")
52 {
53 hidden_->add(QString::fromStdString(result()["app_id"].get_string()));
54
55 usc::CannedQuery cq(SCOPE_PKG + "_" + SCOPE_APP);
56 return usc::ActivationResponse(cq);
57 }
58 else if (action_id_ == "show")
59 {
60 hidden_->remove(QString::fromStdString(result()["app_id"].get_string()));
61
62 usc::CannedQuery cq(SCOPE_PKG + "_" + SCOPE_APP);
63 return usc::ActivationResponse(cq);
64 }
65 return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled);
66}
067
=== added file 'libertine-scope/action.h'
--- libertine-scope/action.h 1970-01-01 00:00:00 +0000
+++ libertine-scope/action.h 2016-06-16 14:35:35 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 * * Authored by:
16 * Kyle Nitzsche <kyle.nitzsche@canonical.com>
17 */
18
19#ifndef SCOPE_ACTION_H_
20#define SCOPE_ACTION_H_
21
22#include "libertine-scope/scope.h"
23#include <unity/scopes/ActionMetadata.h>
24#include <unity/scopes/ActivationQueryBase.h>
25#include <unity/scopes/ActivationResponse.h>
26#include <unity/scopes/Result.h>
27
28class HiddenApps;
29
30class Action : public unity::scopes::ActivationQueryBase {
31 public:
32 Action(unity::scopes::Result const& result,
33 unity::scopes::ActionMetadata const& metadata,
34 std::string const& action_id,
35 std::shared_ptr<HiddenApps> hidden);
36
37 virtual ~Action() = default;
38 virtual unity::scopes::ActivationResponse activate() override;
39
40 private:
41 std::string action_id_;
42 std::string cache_dir_;
43 std::shared_ptr<HiddenApps> hidden_;
44};
45#endif
046
=== added file 'libertine-scope/blacklist.cpp'
--- libertine-scope/blacklist.cpp 1970-01-01 00:00:00 +0000
+++ libertine-scope/blacklist.cpp 2016-06-16 14:35:35 +0000
@@ -0,0 +1,78 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "libertine-scope/blacklist.h"
17
18#include <QFile>
19#include <QTextStream>
20
21namespace
22{
23inline QString
24parse_whitelist_key(QString const& line)
25{
26 QStringList props = line.split("/");
27 return props.length() == 3 ? QString("%1/%2").arg(props[1]).arg(props[2]) : "";
28}
29}
30
31
32Blacklist::
33Blacklist(std::string const& data_directory)
34{
35 parse_blacklist(QString("%1/blacklist").arg(QString::fromStdString(data_directory)));
36}
37
38
39void Blacklist::
40parse_blacklist(QString const& blacklist_file_name)
41{
42 QFile blacklist_file(blacklist_file_name);
43 if (blacklist_file.open(QIODevice::ReadOnly | QIODevice::Text))
44 {
45 QTextStream in(&blacklist_file);
46 while (!in.atEnd())
47 {
48 QString line(in.readLine());
49 if (!line.startsWith("#"))
50 {
51 if (line.startsWith("whitelist"))
52 {
53 auto whitelisted_app = parse_whitelist_key(line);
54 if (!whitelisted_app.isEmpty())
55 {
56 whitelist_.append(parse_whitelist_key(line));
57 }
58 }
59 else
60 {
61 blacklist_.append(line.trimmed());
62 }
63 }
64 }
65 blacklist_file.close();
66 }
67}
68
69
70bool Blacklist::
71app_is_blacklisted(QString const& app_id, std::string const& container_id) const
72{
73 auto global_app_id = QString("all/%1").arg(app_id);
74 auto local_app_id = QString("%1/%2").arg(QString::fromStdString(container_id)).arg(app_id);
75
76 return !(whitelist_.contains(global_app_id) || whitelist_.contains(local_app_id)) &&
77 (blacklist_.contains(global_app_id) || blacklist_.contains(local_app_id));
78}
079
=== added file 'libertine-scope/blacklist.h'
--- libertine-scope/blacklist.h 1970-01-01 00:00:00 +0000
+++ libertine-scope/blacklist.h 2016-06-16 14:35:35 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef BLACKLIST_H
17#define BLACKLIST_H
18
19#include <QStringList>
20
21class Blacklist
22{
23public:
24 explicit Blacklist(std::string const& data_directory);
25 virtual ~Blacklist() = default;
26
27 virtual bool app_is_blacklisted(QString const& app_id, std::string const& container_id) const;
28
29private:
30 void parse_blacklist(QString const& blacklist_file_name);
31
32 QStringList blacklist_;
33 QStringList whitelist_;
34};
35
36#endif // BLACKLIST_H
037
=== added file 'libertine-scope/config.h.in'
--- libertine-scope/config.h.in 1970-01-01 00:00:00 +0000
+++ libertine-scope/config.h.in 2016-06-16 14:35:35 +0000
@@ -0,0 +1,26 @@
1/*
2 * Copyright 2015-2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef LIBERTINE_SCOPE_CONFIG_H_
17#define LIBERTINE_SCOPE_CONFIG_H_
18
19const std::string SCOPE_PKG = "@PACKAGE_NAME@";
20const std::string SCOPE_APP = "@SCOPE_NAME@";
21const std::string ROOT_DEPT_ID = "root_dept";
22const std::string HIDDEN_DEPT_ID = "hidden_dept";
23
24#endif // LIBERTINE_SCOPE_CONFIG_H_
25
26
027
=== added file 'libertine-scope/hidden_apps.cpp'
--- libertine-scope/hidden_apps.cpp 1970-01-01 00:00:00 +0000
+++ libertine-scope/hidden_apps.cpp 2016-06-16 14:35:35 +0000
@@ -0,0 +1,92 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "libertine-scope/hidden_apps.h"
17
18#include <QFile>
19#include <QTextStream>
20
21
22namespace
23{
24QStringList
25get_hidden_apps(const QString& hidden_file_name)
26{
27 QFile hidden_file(hidden_file_name);
28 if (!hidden_file.open(QIODevice::ReadOnly | QIODevice::Text))
29 {
30 return QStringList{};
31 }
32
33 return QString(hidden_file.readAll()).split('\n', QString::SkipEmptyParts);
34}
35}
36
37
38HiddenApps::
39HiddenApps(const std::string &cache_directory)
40 : hidden_file_name_(QString("%1/hidden").arg(QString::fromStdString(cache_directory)))
41 , apps_(get_hidden_apps(hidden_file_name_))
42{
43}
44
45
46bool HiddenApps::
47app_is_hidden(QString const& app_id) const
48{
49 return apps_.contains(app_id);
50}
51
52
53bool HiddenApps::
54empty() const
55{
56 return apps_.empty();
57}
58
59
60void HiddenApps::
61add(const QString &app_id)
62{
63 if (!app_is_hidden(app_id))
64 {
65 QFile hidden_file(hidden_file_name_);
66 if (hidden_file.open(QIODevice::Append | QIODevice::Text))
67 {
68 hidden_file.write(app_id.toUtf8() + "\n");
69 }
70
71 apps_.append(app_id);
72 }
73}
74
75
76void HiddenApps::
77remove(const QString &app_id)
78{
79 if (app_is_hidden(app_id))
80 {
81 apps_.removeAll(app_id);
82
83 QFile hidden_file(hidden_file_name_);
84 if (hidden_file.open(QIODevice::WriteOnly | QIODevice::Text))
85 {
86 for (auto const& app : apps_)
87 {
88 hidden_file.write(app.toUtf8() + "\n");
89 }
90 }
91 }
92}
093
=== added file 'libertine-scope/hidden_apps.h'
--- libertine-scope/hidden_apps.h 1970-01-01 00:00:00 +0000
+++ libertine-scope/hidden_apps.h 2016-06-16 14:35:35 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef HIDDEN_APPS_H
17#define HIDDEN_APPS_H
18
19#include <string>
20#include <QStringList>
21
22class HiddenApps
23{
24public:
25 explicit HiddenApps(const std::string& cache_directory);
26 virtual ~HiddenApps() = default;
27
28 virtual bool app_is_hidden(QString const& app_id) const;
29 virtual bool empty() const;
30 virtual void add(QString const& app_id);
31 virtual void remove(QString const& app_id);
32
33private:
34 QString hidden_file_name_;
35 QStringList apps_;
36};
37
38#endif // HIDDEN_APPS_H
039
=== modified file 'libertine-scope/preview.cpp'
--- libertine-scope/preview.cpp 2016-05-03 13:25:14 +0000
+++ libertine-scope/preview.cpp 2016-06-16 14:35:35 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17#include "libertine-scope/preview.h"17#include "libertine-scope/preview.h"
18#include "libertine-scope/config.h"
18#include <unity/scopes/PreviewReply.h>19#include <unity/scopes/PreviewReply.h>
19#include <unity/scopes/Variant.h>20#include <unity/scopes/Variant.h>
20#include <unity/scopes/VariantBuilder.h>21#include <unity/scopes/VariantBuilder.h>
@@ -57,6 +58,25 @@
57 {"id", usc::Variant("open")},58 {"id", usc::Variant("open")},
58 {"label", usc::Variant("Open")},59 {"label", usc::Variant("Open")},
59 });60 });
61
62 if (result().contains("department_id"))
63 {
64 if (result()["department_id"].get_string() == ROOT_DEPT_ID)
65 {
66 vb.add_tuple({
67 {"id", usc::Variant("hide")},
68 {"label", usc::Variant("Hide")},
69 });
70 }
71 else
72 {
73 vb.add_tuple({
74 {"id", usc::Variant("show")},
75 //Translators: Users tap "Show" button to remove an app from the hidden list of apps: so the meaning is to undo a hide
76 {"label", usc::Variant("Show")},
77 });
78 }
79 }
60 buttons.add_attribute_value("actions", vb.end());80 buttons.add_attribute_value("actions", vb.end());
6181
62 usc::PreviewWidget desc("desc", "text");82 usc::PreviewWidget desc("desc", "text");
6383
=== modified file 'libertine-scope/preview.h'
--- libertine-scope/preview.h 2016-01-04 23:05:30 +0000
+++ libertine-scope/preview.h 2016-06-16 14:35:35 +0000
@@ -33,8 +33,6 @@
3333
34 void34 void
35 run(unity::scopes::PreviewReplyProxy const& reply) override;35 run(unity::scopes::PreviewReplyProxy const& reply) override;
36
37private:
38};36};
3937
40#endif /* LIBERTINE_SCOPE_PREVIEW_H */38#endif /* LIBERTINE_SCOPE_PREVIEW_H */
4139
=== modified file 'libertine-scope/query.cpp'
--- libertine-scope/query.cpp 2016-05-04 17:56:13 +0000
+++ libertine-scope/query.cpp 2016-06-16 14:35:35 +0000
@@ -16,26 +16,66 @@
1616
17#include "libertine-scope/query.h"17#include "libertine-scope/query.h"
18#include "libertine-scope/container.h"18#include "libertine-scope/container.h"
19#include "libertine-scope/config.h"
20#include "libertine-scope/localization.h"
19#include <unity/scopes/CategorisedResult.h>21#include <unity/scopes/CategorisedResult.h>
20#include <unity/scopes/CategoryRenderer.h>22#include <unity/scopes/CategoryRenderer.h>
21#include <unity/scopes/QueryBase.h>23#include <unity/scopes/QueryBase.h>
22#include <unity/scopes/SearchReply.h>24#include <unity/scopes/SearchReply.h>
25#include <unity/scopes/Department.h>
26#include <unity/scopes/OptionSelectorFilter.h>
27#include <unity/scopes/FilterOption.h>
23#include <QString>28#include <QString>
24#include <QStringList>29#include <QStringList>
25#include <QRegExp>30#include <QRegExp>
2631#include <QFile>
32#include <QTextStream>
2733
28namespace usc = unity::scopes;34namespace usc = unity::scopes;
2935
30
31namespace36namespace
32{37{
3338static const auto ROOT_DEPT_TITLE = _("X Apps");
34/**39static const auto HIDDEN_DEPT_TITLE = _("Hidden X Apps");
35 * A custom rendering layout brazenly stolen from the click scope, so they look40static const auto DESCRIPTION_FIELD = "description";
36 * sorta similar. At least until they change theirs.41static const auto APP_ID_FIELD = "app_id";
37 */42static const auto DEPARTMENT_ID_FIELD = "department_id";
38std::string const CATEGORY_APPS_DISPLAY = R"(43static const auto EXCLUDED_APPS_FILTER_TITLE = _("Exclude Apps: ");
44
45struct AppInfo
46{
47 QString container;
48 QString app_id;
49 QString key;
50};
51
52static AppInfo
53parse_app_info(std::string const& uri)
54{
55 QStringList uri_split = QString::fromStdString(uri).split("/");
56 if (uri_split.size() < 4)
57 {
58 return AppInfo{};
59 }
60
61 return AppInfo{uri_split[2], uri_split[3], QString("%1/%2").arg(uri_split[2]).arg(uri_split[3])};
62}
63
64static void
65register_departments(usc::SearchReplyProxy const& reply)
66{
67 usc::CannedQuery departments("libertine-scope.ubuntu");
68 departments.set_department_id(ROOT_DEPT_ID);
69 departments.set_department_id(HIDDEN_DEPT_ID);
70
71 usc::Department::SPtr root_dept{std::move(usc::Department::create("", departments, ROOT_DEPT_TITLE))};
72 root_dept->add_subdepartment(std::move(usc::Department::create(HIDDEN_DEPT_ID, departments, HIDDEN_DEPT_TITLE)));
73
74 reply->register_departments(root_dept);
75}
76
77
78static const auto CATEGORY_APPS_DISPLAY = R"(
39 {79 {
40 "schema-version" : 1,80 "schema-version" : 1,
41 "template" : {81 "template" : {
@@ -53,15 +93,37 @@
53 }93 }
54)";94)";
5595
96
97static const auto CATEGORY_HINT = R"(
98 {
99 "schema-version": 1,
100 "template": {
101 "category-layout": "grid",
102 "card-size": "large",
103 "card-layout": "horizontal"
104 },
105 "components": {
106 "title": "title"
107 }
108 }
109)";
56} // anonymous namespace110} // anonymous namespace
57111
58112
113std::string const Query::NO_RESULTS_HINT = _("No XApps available. Install new applications with the Libertine Manager.");
114std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All XApps hidden. Reset filters or check the Hidden XApps department.");
115
116
59Query::117Query::
60Query(usc::CannedQuery const& query,118Query(usc::CannedQuery const& query,
61 usc::SearchMetadata const& metadata,119 usc::SearchMetadata const& metadata,
62 Libertine::Factory const& libertine_factory)120 Libertine::Factory const& libertine_factory,
63: usc::SearchQueryBase(query, metadata)121 std::shared_ptr<HiddenApps> hidden,
64, libertine_factory_(libertine_factory)122 std::shared_ptr<Blacklist> blacklist)
123 : usc::SearchQueryBase(query, metadata)
124 , libertine_(libertine_factory())
125 , hidden_(hidden)
126 , blacklist_(blacklist)
65{127{
66}128}
67129
@@ -72,44 +134,127 @@
72}134}
73135
74136
75unity::scopes::VariantMap137QStringList Query::
76Query::settings() const138make_filters(usc::SearchReplyProxy const& reply) const
77{139{
78 return SearchQueryBase::settings();140 auto filter_state = query().filter_state();
141 QStringList excludes_by_filter;
142 std::list<usc::FilterBase::SCPtr> app_filters;
143
144 //make exclude scope filter for apps
145 for (auto const& container: libertine_->get_container_list())
146 {
147 usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(),
148 EXCLUDED_APPS_FILTER_TITLE + container->name(),
149 true)};
150 // filter apps from blacklist
151 for (auto const& app: container->app_launchers())
152 {
153 auto app_info = parse_app_info(app.uri());
154
155 if (hidden_->app_is_hidden(app_info.key))
156 {
157 continue;
158 }
159
160 if (!blacklist_->app_is_blacklisted(app_info.app_id, container->id()))
161 {
162 filter->add_option(app_info.key.toStdString(), app.name());
163 }
164 }
165
166 // get apps manually filtered by user
167 if (filter->has_active_option(filter_state))
168 {
169 auto filteredApps = filter->active_options(filter_state);
170 for (auto const &app: filteredApps)
171 {
172 excludes_by_filter.append(QString::fromStdString(app->id()));
173 }
174 }
175
176 if (!filter->options().empty())
177 {
178 app_filters.push_back(filter);
179 }
180 }
181
182 if (!app_filters.empty())
183 {
184 reply->push(app_filters, filter_state);
185 }
186
187 return excludes_by_filter;
79}188}
80189
81190
82QStringList191void Query::
83Query::blacklist() const192show_hint(usc::SearchReplyProxy const& reply,
193 std::string const& reason) const
84{194{
85 QStringList blacklistedApps;195 auto hint_category = reply->register_category("hint", "", "", usc::CategoryRenderer(CATEGORY_HINT));
86 auto blacklist = settings()["blacklist"];196 usc::CategorisedResult res(hint_category);
87 if (!blacklist.is_null()) {197 res.set_uri(usc::CannedQuery(query()).to_uri());
88 blacklistedApps = QString::fromStdString(blacklist.get_string())198 res.set_title(reason);
89 .remove("\"")199 reply->push(res);
90 .split(";", QString::SkipEmptyParts);
91 }
92 return blacklistedApps;
93}200}
94201
95202
96void Query::203void Query::
97run(usc::SearchReplyProxy const& reply)204run(usc::SearchReplyProxy const& reply)
98{205{
99 auto blacklistedApps = blacklist();206 if (!hidden_->empty())
100 QRegExp re(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);207 {
101 Libertine::UPtr libertine = libertine_factory_();208 register_departments(reply);
102209 }
103 for (auto const& container: libertine->get_container_list())210
211 // only provide filters in root department
212 QStringList excludes_by_filter;
213 if (query().department_id().empty())
214 {
215 excludes_by_filter = make_filters(reply);
216 }
217
218 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);
219 bool has_no_apps = true,
220 all_filtered = true;
221
222 for (auto const& container: libertine_->get_container_list())
104 {223 {
105 auto category = reply->register_category(container->id(),224 auto category = reply->register_category(container->id(),
106 container->name(),225 container->name(),
107 "Application",226 "Application",
108 usc::CategoryRenderer(CATEGORY_APPS_DISPLAY));227 usc::CategoryRenderer(CATEGORY_APPS_DISPLAY));
228
109 for (auto const& app: container->app_launchers())229 for (auto const& app: container->app_launchers())
110 {230 {
111 if (!(re.isEmpty() || QString::fromStdString(app.name()).contains(re))231 has_no_apps = false;
112 || blacklistedApps.contains(QString::fromStdString(app.name())))232 if (!(search_query.isEmpty() || QString::fromStdString(app.name()).contains(search_query)))
233 {
234 continue;
235 }
236
237 auto app_info = parse_app_info(app.uri());
238
239 if (blacklist_->app_is_blacklisted(app_info.app_id, container->id()))
240 {
241 continue;
242 }
243
244 if (excludes_by_filter.contains(app_info.key))
245 {
246 continue;
247 }
248
249 // ignore hidden apps in root department
250 if (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID)
251 {
252 if (hidden_->app_is_hidden(app_info.key))
253 {
254 continue;
255 }
256 }
257 else if (!hidden_->app_is_hidden(app_info.key))
113 {258 {
114 continue;259 continue;
115 }260 }
@@ -118,12 +263,25 @@
118 result.set_title(app.name());263 result.set_title(app.name());
119 result.set_art(app.icon());264 result.set_art(app.icon());
120 result.set_uri(app.uri());265 result.set_uri(app.uri());
121 result["description"] = app.description();266 result[DESCRIPTION_FIELD] = app.description();
267 result[APP_ID_FIELD] = app_info.key.toStdString();
268 result[DEPARTMENT_ID_FIELD] = (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID) ? ROOT_DEPT_ID : HIDDEN_DEPT_ID;
269
122 if (!reply->push(result))270 if (!reply->push(result))
123 {271 {
124 break;272 return;
125 }273 }
274
275 all_filtered = false;
126 }276 }
127 }277 }
278
279 if (has_no_apps)
280 {
281 show_hint(reply, NO_RESULTS_HINT);
282 }
283 else if (all_filtered)
284 {
285 show_hint(reply, ALL_RESULTS_FILTERED_HINT);
286 }
128}287}
129
130288
=== modified file 'libertine-scope/query.h'
--- libertine-scope/query.h 2016-05-04 17:56:13 +0000
+++ libertine-scope/query.h 2016-06-16 14:35:35 +0000
@@ -17,10 +17,11 @@
17#define LIBERTINE_SCOPE_QUERY_H_17#define LIBERTINE_SCOPE_QUERY_H_
1818
19#include "libertine-scope/libertine.h"19#include "libertine-scope/libertine.h"
20#include "libertine-scope/blacklist.h"
21#include "libertine-scope/hidden_apps.h"
20#include <unity/scopes/ReplyProxyFwd.h>22#include <unity/scopes/ReplyProxyFwd.h>
21#include <unity/scopes/SearchQueryBase.h>23#include <unity/scopes/SearchQueryBase.h>
2224#include <QStringList>
23class QStringList;
2425
2526
26/**27/**
@@ -30,25 +31,32 @@
30: public unity::scopes::SearchQueryBase31: public unity::scopes::SearchQueryBase
31{32{
32public:33public:
33 Query(unity::scopes::CannedQuery const& query,34 Query(unity::scopes::CannedQuery const& query,
34 unity::scopes::SearchMetadata const& metadata,35 unity::scopes::SearchMetadata const& metadata,
35 Libertine::Factory const& libertine_factory);36 Libertine::Factory const& libertine_factory,
3637 std::shared_ptr<HiddenApps> hidden_apps,
37 ~Query() = default;38 std::shared_ptr<Blacklist> blacklist);
3839
39 void40 ~Query() = default;
40 cancelled() override;41
4142 virtual void
42 void43 cancelled() override;
43 run(unity::scopes::SearchReplyProxy const& reply) override;44
4445 void
45 // Overriding base class method to add ability to test46 run(unity::scopes::SearchReplyProxy const& reply) override;
46 virtual unity::scopes::VariantMap settings() const;47
48 static std::string const NO_RESULTS_HINT;
49 static std::string const ALL_RESULTS_FILTERED_HINT;
4750
48private:51private:
49 QStringList blacklist() const;52 QStringList get_hidden_department() const;
53 QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const;
54 void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;
55 void parse_blacklist(const std::string& data_dir);
5056
51 Libertine::Factory libertine_factory_;57 Libertine::UPtr libertine_;
58 std::shared_ptr<HiddenApps> hidden_;
59 std::shared_ptr<Blacklist> blacklist_;
52};60};
5361
54#endif // LIBERTINE_SCOPE_QUERY_H_62#endif // LIBERTINE_SCOPE_QUERY_H_
5563
=== modified file 'libertine-scope/scope.cpp'
--- libertine-scope/scope.cpp 2016-01-19 21:10:09 +0000
+++ libertine-scope/scope.cpp 2016-06-16 14:35:35 +0000
@@ -17,40 +17,17 @@
1717
18#include "libertine-scope/preview.h"18#include "libertine-scope/preview.h"
19#include "libertine-scope/query.h"19#include "libertine-scope/query.h"
20#include <localization.h>20#include "libertine-scope/action.h"
21#include "libertine-scope/localization.h"
21#include <sstream>22#include <sstream>
22#include <unity/scopes/ActivationResponse.h>
23#include <url-dispatcher.h>23#include <url-dispatcher.h>
24#include <QFile>
25#include <QTextStream>
26#include <QString>
2427
2528
26namespace usc = unity::scopes;29namespace usc = unity::scopes;
2730
28namespace
29{
30
31/**
32 * @todo move this class into its own source file.
33 */
34class ScopeActivation
35: public usc::ActivationQueryBase
36{
37public:
38 ScopeActivation(usc::Result const& result,
39 usc::ActionMetadata const& metadata)
40 : ActivationQueryBase(result, metadata)
41 { }
42
43 usc::ActivationResponse
44 activate() override
45 {
46 return usc::ActivationResponse(status);
47 }
48
49 usc::ActivationResponse::Status status = usc::ActivationResponse::Status::NotHandled;
50};
51
52} // anonymous namespace
53
5431
55Scope::32Scope::
56Scope(Libertine::Factory const& libertine_factory)33Scope(Libertine::Factory const& libertine_factory)
@@ -79,7 +56,11 @@
79search(usc::CannedQuery const& query,56search(usc::CannedQuery const& query,
80 usc::SearchMetadata const& metadata)57 usc::SearchMetadata const& metadata)
81{58{
82 return usc::SearchQueryBase::UPtr(new Query(query, metadata, libertine_factory_));59 return usc::SearchQueryBase::UPtr(new Query(query,
60 metadata,
61 libertine_factory_,
62 std::make_shared<HiddenApps>(cache_directory()),
63 std::make_shared<Blacklist>(scope_directory())));
83}64}
8465
8566
@@ -97,14 +78,10 @@
97 std::string const& /* widget_id */,78 std::string const& /* widget_id */,
98 std::string const& action_id)79 std::string const& action_id)
99{80{
100 auto activation = new ScopeActivation(result, metadata);81 return usc::ActivationQueryBase::UPtr(new Action(result,
10182 metadata,
102 if (action_id == "open")83 action_id,
103 {84 std::make_shared<HiddenApps>(cache_directory())));
104 url_dispatch_send(result.uri().c_str() , NULL, NULL);
105 }
106
107 return usc::ActivationQueryBase::UPtr(activation);
108}85}
10986
11087
11188
=== modified file 'po/en_AU.po'
--- po/en_AU.po 2016-06-09 06:33:15 +0000
+++ po/en_AU.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-21 11:19+0000\n"11"PO-Revision-Date: 2016-05-21 11:19+0000\n"
12"Last-Translator: Jared Norris <jarednorris@ubuntu.com>\n"12"Last-Translator: Jared Norris <jarednorris@ubuntu.com>\n"
13"Language-Team: English (Australia) <en_AU@li.org>\n"13"Language-Team: English (Australia) <en_AU@li.org>\n"
14"Language: \n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'po/en_GB.po'
--- po/en_GB.po 2016-06-09 06:33:15 +0000
+++ po/en_GB.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-20 16:47+0000\n"11"PO-Revision-Date: 2016-05-20 16:47+0000\n"
12"Last-Translator: Andi Chandler <Unknown>\n"12"Last-Translator: Andi Chandler <Unknown>\n"
13"Language-Team: English (United Kingdom) <en_GB@li.org>\n"13"Language-Team: English (United Kingdom) <en_GB@li.org>\n"
14"Language: \n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'po/es.po'
--- po/es.po 2016-06-09 06:33:15 +0000
+++ po/es.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-06-04 22:37+0000\n"11"PO-Revision-Date: 2016-06-04 22:37+0000\n"
12"Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"12"Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"
13"Language-Team: Spanish <es@li.org>\n"13"Language-Team: Spanish <es@li.org>\n"
14"Language: es\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
@@ -23,5 +24,8 @@
2324
24#: ../data/libertine-scope.ini.in.h:225#: ../data/libertine-scope.ini.in.h:2
25msgid "Surface and launch DEB-packaged X11-based applications."26msgid "Surface and launch DEB-packaged X11-based applications."
26msgstr ""27msgstr "Mostrar y ejecutar aplicaciones basadas en X11 y empaquetadas en DEB."
27"Mostrar y ejecutar aplicaciones basadas en X11 y empaquetadas en DEB."28
29#, fuzzy
30#~ msgid "X Apps"
31#~ msgstr "XApps"
2832
=== modified file 'po/fi.po'
--- po/fi.po 2016-06-09 06:33:15 +0000
+++ po/fi.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-30 07:34+0000\n"11"PO-Revision-Date: 2016-05-30 07:34+0000\n"
12"Last-Translator: Jiri Grönroos <Unknown>\n"12"Last-Translator: Jiri Grönroos <Unknown>\n"
13"Language-Team: Finnish <fi@li.org>\n"13"Language-Team: Finnish <fi@li.org>\n"
14"Language: fi\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'po/fr.po'
--- po/fr.po 2016-06-09 06:33:15 +0000
+++ po/fr.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-21 12:23+0000\n"11"PO-Revision-Date: 2016-05-21 12:23+0000\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: French <fr@li.org>\n"13"Language-Team: French <fr@li.org>\n"
14"Language: fr\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'po/gl.po'
--- po/gl.po 2016-06-09 06:33:15 +0000
+++ po/gl.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-06-06 23:23+0000\n"11"PO-Revision-Date: 2016-06-06 23:23+0000\n"
12"Last-Translator: Marcos Lans <Unknown>\n"12"Last-Translator: Marcos Lans <Unknown>\n"
13"Language-Team: Galician <gl@li.org>\n"13"Language-Team: Galician <gl@li.org>\n"
14"Language: gl\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
@@ -25,3 +26,7 @@
25msgid "Surface and launch DEB-packaged X11-based applications."26msgid "Surface and launch DEB-packaged X11-based applications."
26msgstr ""27msgstr ""
27"Inicia e executa aplicativos baseados en X11 empaquetados en formato DEB."28"Inicia e executa aplicativos baseados en X11 empaquetados en formato DEB."
29
30#, fuzzy
31#~ msgid "X Apps"
32#~ msgstr "XApps"
2833
=== modified file 'po/libertine-scope.pot'
--- po/libertine-scope.pot 2016-06-02 17:13:50 +0000
+++ po/libertine-scope.pot 2016-06-16 14:35:35 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2016-06-02 13:05-0400\n"11"POT-Creation-Date: 2016-06-16 08:41-0400\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -24,3 +24,25 @@
24#: ../data/libertine-scope.ini.in.h:224#: ../data/libertine-scope.ini.in.h:2
25msgid "Surface and launch DEB-packaged X11-based applications."25msgid "Surface and launch DEB-packaged X11-based applications."
26msgstr ""26msgstr ""
27
28#: ../libertine-scope/query.cpp:38
29msgid "X Apps"
30msgstr ""
31
32#: ../libertine-scope/query.cpp:39
33msgid "Hidden X Apps"
34msgstr ""
35
36#: ../libertine-scope/query.cpp:43
37msgid "Exclude Apps: "
38msgstr ""
39
40#. anonymous namespace
41#: ../libertine-scope/query.cpp:113
42msgid ""
43"No XApps available. Install new applications with the Libertine Manager."
44msgstr ""
45
46#: ../libertine-scope/query.cpp:114
47msgid "All XApps hidden. Reset filters or check the Hidden XApps department."
48msgstr ""
2749
=== modified file 'po/ms.po'
--- po/ms.po 2016-06-09 06:33:15 +0000
+++ po/ms.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-22 00:24+0000\n"11"PO-Revision-Date: 2016-05-22 00:24+0000\n"
12"Last-Translator: abuyop <Unknown>\n"12"Last-Translator: abuyop <Unknown>\n"
13"Language-Team: Malay <ms@li.org>\n"13"Language-Team: Malay <ms@li.org>\n"
14"Language: ms\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'po/pt.po'
--- po/pt.po 2016-06-09 06:33:15 +0000
+++ po/pt.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-20 16:05+0000\n"11"PO-Revision-Date: 2016-05-20 16:05+0000\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: Portuguese <pt@li.org>\n"13"Language-Team: Portuguese <pt@li.org>\n"
14"Language: pt\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'po/uk.po'
--- po/uk.po 2016-06-09 06:33:15 +0000
+++ po/uk.po 2016-06-16 14:35:35 +0000
@@ -6,15 +6,16 @@
6msgid ""6msgid ""
7msgstr ""7msgstr ""
8"Project-Id-Version: libertine-scope\n"8"Project-Id-Version: libertine-scope\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2016-06-08 19:33+0000\n"10"POT-Creation-Date: 2016-06-02 13:05-0400\n"
11"PO-Revision-Date: 2016-05-20 15:56+0000\n"11"PO-Revision-Date: 2016-05-20 15:56+0000\n"
12"Last-Translator: Yuri Chornoivan <yurchor@gmail.com>\n"12"Last-Translator: Yuri Chornoivan <yurchor@gmail.com>\n"
13"Language-Team: Ukrainian <uk@li.org>\n"13"Language-Team: Ukrainian <uk@li.org>\n"
14"Language: uk\n"
14"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"16"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n"18"X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n"
18"X-Generator: Launchpad (build 18097)\n"19"X-Generator: Launchpad (build 18097)\n"
1920
20#: ../data/libertine-scope.ini.in.h:121#: ../data/libertine-scope.ini.in.h:1
2122
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2016-05-03 13:25:14 +0000
+++ tests/CMakeLists.txt 2016-06-16 14:35:35 +0000
@@ -3,24 +3,27 @@
3set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")3set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
4add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")4add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
55
6add_executable(libertine_scope_tests6function(create_test test_name)
7 fake_container.cpp7 add_executable(${test_name}_exe
8 fake_libertine.cpp8 fake_container.cpp
99 fake_libertine.cpp
10 # tests10 ${test_name}.cpp
11 test_scope.cpp11 )
12 test_preview.cpp12
13 test_query.cpp13 target_link_libraries(${test_name}_exe
14)14 scope
1515 Qt5::Core
16target_link_libraries(libertine_scope_tests16 gmock
17 scope17 gmock_main
18 Qt5::Core18 )
19 gmock19
20 gmock_main20 add_test(${test_name} ${test_name}_exe)
21)21endfunction(create_test)
2222
23add_test(test_scope libertine_scope_tests)23create_test(test_scope)
24add_test(test_preview libertine_scope_tests)24create_test(test_preview)
25add_test(test_query libertine_scope_tests)25create_test(test_query)
2626create_test(test_hidden_apps)
27create_test(test_blacklist)
28
29file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
2730
=== modified file 'tests/TypedScopeFixture.h'
--- tests/TypedScopeFixture.h 2016-01-19 05:10:54 +0000
+++ tests/TypedScopeFixture.h 2016-06-16 14:35:35 +0000
@@ -85,6 +85,7 @@
85 {85 {
86 TypedScopeFixtureHelper::set_registry(scope, registry_proxy);86 TypedScopeFixtureHelper::set_registry(scope, registry_proxy);
87 TypedScopeFixtureHelper::set_scope_directory(scope, "/tmp");87 TypedScopeFixtureHelper::set_scope_directory(scope, "/tmp");
88 TypedScopeFixtureHelper::set_cache_directory(scope, "/tmp");
88 TypedScopeFixtureHelper::set_app_directory(scope, "/tmp");89 TypedScopeFixtureHelper::set_app_directory(scope, "/tmp");
89 }90 }
9091
9192
=== added directory 'tests/data'
=== added file 'tests/data/blacklist'
--- tests/data/blacklist 1970-01-01 00:00:00 +0000
+++ tests/data/blacklist 2016-06-16 14:35:35 +0000
@@ -0,0 +1,9 @@
1# simple blacklisting`
2container1/app1
3all/app2
4
5# blacklisted but overriden by whitelisting
6all/app3
7all/app4
8whitelist/container1/app3
9whitelist/all/app4
010
=== added file 'tests/data/hidden'
--- tests/data/hidden 1970-01-01 00:00:00 +0000
+++ tests/data/hidden 2016-06-16 14:35:35 +0000
@@ -0,0 +1,1 @@
1container1/app1
02
=== modified file 'tests/fake_container.cpp'
--- tests/fake_container.cpp 2016-04-27 17:53:30 +0000
+++ tests/fake_container.cpp 2016-06-16 14:35:35 +0000
@@ -42,10 +42,9 @@
42 }42 }
43};43};
4444
45
46FakeContainer::45FakeContainer::
47FakeContainer(std::string const& json_string)46FakeContainer(std::string const& json_string)
48: Container("fakeId", "fakeName")47: Container("fake-container", "fake-container")
49{48{
50 QJsonDocument json = QJsonDocument::fromJson(QByteArray::fromStdString(json_string), nullptr);49 QJsonDocument json = QJsonDocument::fromJson(QByteArray::fromStdString(json_string), nullptr);
51 QJsonObject object = json.object();50 QJsonObject object = json.object();
5251
=== modified file 'tests/fake_container_json.h'
--- tests/fake_container_json.h 2016-04-27 17:53:30 +0000
+++ tests/fake_container_json.h 2016-06-16 14:35:35 +0000
@@ -32,7 +32,7 @@
32 "name": "Panel Manager",32 "name": "Panel Manager",
33 "no_display": false,33 "no_display": false,
34 "description": "some description",34 "description": "some description",
35 "uri": "some/uri"35 "uri": "some/uri/pad1/pad2/"
36 },36 },
37 {37 {
38 "desktop_file_name": "/home/someuser/.cache/libertine-container/fake1/rootfs/usr/share/applications/sakura.desktop",38 "desktop_file_name": "/home/someuser/.cache/libertine-container/fake1/rootfs/usr/share/applications/sakura.desktop",
@@ -44,7 +44,7 @@
44 "name": "Sakura",44 "name": "Sakura",
45 "no_display": false,45 "no_display": false,
46 "description": "some other description",46 "description": "some other description",
47 "uri": "some/other/uri"47 "uri": "some/other/uri/pad"
48 }48 }
49 ]49 ]
50}50}
5151
=== modified file 'tests/fake_libertine.cpp'
--- tests/fake_libertine.cpp 2016-01-19 00:16:56 +0000
+++ tests/fake_libertine.cpp 2016-06-16 14:35:35 +0000
@@ -25,12 +25,6 @@
25}25}
2626
2727
28FakeLibertine::
29~FakeLibertine()
30{
31}
32
33
34Libertine::ContainerList const& FakeLibertine::28Libertine::ContainerList const& FakeLibertine::
35get_container_list() const29get_container_list() const
36{30{
3731
=== modified file 'tests/fake_libertine.h'
--- tests/fake_libertine.h 2016-01-19 21:10:09 +0000
+++ tests/fake_libertine.h 2016-06-16 14:35:35 +0000
@@ -27,9 +27,9 @@
27: public Libertine27: public Libertine
28{28{
29public:29public:
30 ~FakeLibertine();30 virtual ~FakeLibertine() = default;
3131
32 Libertine::ContainerList const&32 virtual Libertine::ContainerList const&
33 get_container_list() const override;33 get_container_list() const override;
3434
35 static Libertine::UPtr35 static Libertine::UPtr
3636
=== added file 'tests/test_blacklist.cpp'
--- tests/test_blacklist.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_blacklist.cpp 2016-06-16 14:35:35 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "libertine-scope/blacklist.h"
17#include <gtest/gtest.h>
18#include <QDir>
19#include <QTemporaryDir>
20
21
22namespace
23{
24class TestBlacklistFixture : public ::testing::Test
25{
26public:
27 TestBlacklistFixture()
28 : blacklist(QString("%1/data").arg(QDir::currentPath()).toStdString())
29 {
30 }
31
32protected:
33 Blacklist blacklist;
34};
35
36TEST_F(TestBlacklistFixture, ReturnsFalseWhenFileDoesNotExist)
37{
38 EXPECT_FALSE(Blacklist(QTemporaryDir().path().toStdString()).app_is_blacklisted("app1", "container1"));
39}
40
41TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsNotInTheList)
42{
43 EXPECT_FALSE(blacklist.app_is_blacklisted("app5", "container1"));
44}
45
46TEST_F(TestBlacklistFixture, ReturnsTrueWhenAppIsBlacklistedLocally)
47{
48 EXPECT_TRUE(blacklist.app_is_blacklisted("app1", "container1"));
49}
50
51TEST_F(TestBlacklistFixture, ReturnsTrueWhenAppIsBlacklistedGlobally)
52{
53 EXPECT_TRUE(blacklist.app_is_blacklisted("app2", "container2"));
54}
55
56TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsWhitelistedLocally)
57{
58 EXPECT_FALSE(blacklist.app_is_blacklisted("app3", "container1"));
59}
60
61TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsWhitelistedGlobally)
62{
63 EXPECT_FALSE(blacklist.app_is_blacklisted("app4", "container2"));
64}
65}
066
=== added file 'tests/test_hidden_apps.cpp'
--- tests/test_hidden_apps.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_hidden_apps.cpp 2016-06-16 14:35:35 +0000
@@ -0,0 +1,107 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, version 3, as published by the
6 * Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "libertine-scope/hidden_apps.h"
17#include <gtest/gtest.h>
18#include <QDir>
19#include <QTemporaryDir>
20
21namespace
22{
23class TestHiddenAppsFixture : public ::testing::Test
24{
25public:
26 TestHiddenAppsFixture()
27 : hidden(QString("%1/data").arg(QDir::currentPath()).toStdString())
28 {
29 }
30
31 virtual void SetUp()
32 {
33 QFile file(QString("%1/data/hidden").arg(QDir::currentPath()));
34 if (file.open(QIODevice::ReadOnly | QIODevice::Text))
35 {
36 original_file_contents = file.readAll();
37 }
38 }
39
40 virtual void TearDown()
41 {
42 QFile file(QString("%1/data/hidden").arg(QDir::currentPath()));
43 if (file.open(QIODevice::WriteOnly | QIODevice::Text))
44 {
45 file.write(original_file_contents);
46 }
47 }
48
49protected:
50 HiddenApps hidden;
51 QByteArray original_file_contents;
52};
53
54
55TEST_F(TestHiddenAppsFixture, HiddenReturnsFalseWhenFileDoesNotExist)
56{
57 EXPECT_FALSE(HiddenApps(QTemporaryDir().path().toStdString()).app_is_hidden("container1/app1"));
58}
59
60TEST_F(TestHiddenAppsFixture, HiddenReturnsFalseWhenAppNotListed)
61{
62 EXPECT_FALSE(hidden.app_is_hidden("container2/app1"));
63}
64
65TEST_F(TestHiddenAppsFixture, HiddenReturnsFalseWhenAppIsListed)
66{
67 EXPECT_TRUE(hidden.app_is_hidden("container1/app1"));
68}
69
70TEST_F(TestHiddenAppsFixture, AddAppendsAppToFile)
71{
72 ASSERT_FALSE(hidden.app_is_hidden("container1/app6"));
73 hidden.add("container1/app6");
74 ASSERT_TRUE(hidden.app_is_hidden("container1/app6"));
75
76 QFile file(QString("%1/data/hidden").arg(QDir::currentPath()));
77 ASSERT_TRUE(file.open(QIODevice::ReadOnly | QIODevice::Text));
78 auto contents = QString(file.readAll()).split('\n', QString::SkipEmptyParts);
79 EXPECT_EQ("container1/app6", contents.last());
80}
81
82TEST_F(TestHiddenAppsFixture, AddDoesNotAppendWhenAppAlreadyInFile)
83{
84 ASSERT_TRUE(hidden.app_is_hidden("container1/app1"));
85 hidden.add("container1/app1");
86
87 QFile file(QString("%1/data/hidden").arg(QDir::currentPath()));
88 ASSERT_TRUE(file.open(QIODevice::ReadOnly | QIODevice::Text));
89 auto contents = QString(file.readAll()).split('\n', QString::SkipEmptyParts);
90 EXPECT_EQ(1, contents.count("container1/app1"));
91}
92
93TEST_F(TestHiddenAppsFixture, RemoveDeletesLineFromFile)
94{
95 ASSERT_FALSE(hidden.app_is_hidden("container1/app6"));
96 hidden.add("container1/app6");
97 ASSERT_TRUE(hidden.app_is_hidden("container1/app6"));
98
99 hidden.remove("container1/app6");
100 ASSERT_FALSE(hidden.app_is_hidden("container1/app6"));
101
102 QFile file(QString("%1/data/hidden").arg(QDir::currentPath()));
103 ASSERT_TRUE(file.open(QIODevice::ReadOnly | QIODevice::Text));
104 auto contents = QString(file.readAll()).split('\n', QString::SkipEmptyParts);
105 EXPECT_NE("container1/app6", contents.last());
106}
107}
0108
=== modified file 'tests/test_preview.cpp'
--- tests/test_preview.cpp 2016-04-27 17:53:30 +0000
+++ tests/test_preview.cpp 2016-06-16 14:35:35 +0000
@@ -28,6 +28,7 @@
28TEST(TestPreview, pushesWidgetsWithAppInformation)28TEST(TestPreview, pushesWidgetsWithAppInformation)
29{29{
30 unity::scopes::testing::Result result;30 unity::scopes::testing::Result result;
31 result["department_id"] = "";
31 unity::scopes::ActionMetadata metadata("en_US", "phone");32 unity::scopes::ActionMetadata metadata("en_US", "phone");
3233
33 std::unique_ptr<unity::scopes::PreviewWidgetList> list(new unity::scopes::PreviewWidgetList());34 std::unique_ptr<unity::scopes::PreviewWidgetList> list(new unity::scopes::PreviewWidgetList());
@@ -57,7 +58,7 @@
57 EXPECT_EQ("actions", buttons.widget_type());58 EXPECT_EQ("actions", buttons.widget_type());
5859
59 auto buttons_actions = buttons.attribute_values()["actions"].get_array();60 auto buttons_actions = buttons.attribute_values()["actions"].get_array();
60 ASSERT_EQ(1, buttons_actions.size());61 ASSERT_EQ(2, buttons_actions.size());
61 EXPECT_EQ("open", buttons_actions[0].get_dict()["id"].get_string());62 EXPECT_EQ("open", buttons_actions[0].get_dict()["id"].get_string());
62 EXPECT_EQ("Open", buttons_actions[0].get_dict()["label"].get_string());63 EXPECT_EQ("Open", buttons_actions[0].get_dict()["label"].get_string());
63}64}
6465
=== modified file 'tests/test_query.cpp'
--- tests/test_query.cpp 2016-04-27 18:37:46 +0000
+++ tests/test_query.cpp 2016-06-16 14:35:35 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17#include "libertine-scope/query.h"17#include "libertine-scope/query.h"
18#include "libertine-scope/config.h"
18#include "tests/fake_libertine.h"19#include "tests/fake_libertine.h"
19#include <unity/scopes/SearchMetadata.h>20#include <unity/scopes/SearchMetadata.h>
20#include <unity/scopes/CannedQuery.h>21#include <unity/scopes/CannedQuery.h>
@@ -34,19 +35,19 @@
34 "app_launchers": [{35 "app_launchers": [{
35 "name": "LibreOffice",36 "name": "LibreOffice",
36 "no_display": false,37 "no_display": false,
37 "uri": "appid://fake/libreoffice/0.0",38 "uri": "appid://fake-container/libreoffice/0.0",
38 "icons": ["file:///lo.png"],39 "icons": ["file:///lo.png"],
39 "description": "libreoffice!"40 "description": "libreoffice!"
40 }, {41 }, {
41 "name": "Linux",42 "name": "Linux",
42 "no_display": true,43 "no_display": true,
43 "uri": "appid://fake/linux/0.0",44 "uri": "appid://fake-container/linux/0.0",
44 "icons": ["file:///nix.png"],45 "icons": ["file:///nix.png"],
45 "description": "linux!"46 "description": "linux!"
46 }, {47 }, {
47 "name": "Library",48 "name": "Library",
48 "no_display": false,49 "no_display": false,
49 "uri": "appid://fake/library/0.0",50 "uri": "appid://fake-container/library/0.0",
50 "icons": ["file:///lib.png"],51 "icons": ["file:///lib.png"],
51 "description": "library!"52 "description": "library!"
52 }]53 }]
@@ -66,6 +67,30 @@
66};67};
6768
6869
70class MockHiddenApps : public HiddenApps
71{
72public:
73 MockHiddenApps()
74 : HiddenApps("")
75 {
76 }
77
78 MOCK_CONST_METHOD1(app_is_hidden, bool(QString const&));
79 MOCK_CONST_METHOD0(empty, bool());
80};
81
82class MockBlacklist : public Blacklist
83{
84public:
85 MockBlacklist()
86 : Blacklist("")
87 {
88 }
89
90 MOCK_CONST_METHOD2(app_is_blacklisted, bool(QString const&, std::string const&));
91};
92
93
69MATCHER_P4(ResultPropertiesMatch, title, art, description, uri, "")94MATCHER_P4(ResultPropertiesMatch, title, art, description, uri, "")
70{95{
71 return arg.contains("title") && arg.contains("art") && arg.contains("description") && arg.contains("uri") &&96 return arg.contains("title") && arg.contains("art") && arg.contains("description") && arg.contains("uri") &&
@@ -76,6 +101,12 @@
76}101}
77102
78103
104MATCHER_P(ResultTitleMatch, title, "")
105{
106 return arg.contains("title") && arg["title"] == unity::scopes::Variant(title);
107}
108
109
79class TestQueryFixture : public ::testing::Test110class TestQueryFixture : public ::testing::Test
80{111{
81public:112public:
@@ -84,13 +115,25 @@
84 , canned_query("libertine-scope")115 , canned_query("libertine-scope")
85 , reply()116 , reply()
86 , proxy(&reply, [](unity::scopes::SearchReply*) {})117 , proxy(&reply, [](unity::scopes::SearchReply*) {})
87 , category(std::make_shared<FakeCategory>("fakeId", "fake-container", "Application", unity::scopes::CategoryRenderer()))118 , category(std::make_shared<FakeCategory>("fake-container", "fake-container", "Application", unity::scopes::CategoryRenderer()))
88 {119 , hidden(new testing::NiceMock<MockHiddenApps>())
120 , blacklist(new testing::NiceMock<MockBlacklist>())
121 {
122 }
123
124 virtual void SetUp()
125 {
126 EXPECT_CALL(*blacklist, app_is_blacklisted(testing::_, "fake-container"))
127 .WillRepeatedly(testing::Return(false));
128 EXPECT_CALL(*hidden, empty())
129 .WillRepeatedly(testing::Return(true));
130 EXPECT_CALL(*hidden, app_is_hidden(testing::_))
131 .WillRepeatedly(testing::Return(false));
89 }132 }
90133
91 void expect_registry()134 void expect_registry()
92 {135 {
93 EXPECT_CALL(reply, register_category("fakeId", "fake-container", "Application", testing::_)).WillOnce(testing::Return(category));136 EXPECT_CALL(reply, register_category("fake-container", "fake-container", "Application", testing::_)).WillOnce(testing::Return(category));
94 }137 }
95138
96 void expect_push(std::string title, std::string art, std::string description, std::string appId, bool success = true)139 void expect_push(std::string title, std::string art, std::string description, std::string appId, bool success = true)
@@ -100,17 +143,17 @@
100143
101 void expect_push_libreoffice(bool success = true)144 void expect_push_libreoffice(bool success = true)
102 {145 {
103 expect_push("LibreOffice", "file:///lo.png", "libreoffice!", "appid://fake/libreoffice/0.0", success);146 expect_push("LibreOffice", "file:///lo.png", "libreoffice!", "appid://fake-container/libreoffice/0.0", success);
104 }147 }
105148
106 void expect_push_library(bool success = true)149 void expect_push_library(bool success = true)
107 {150 {
108 expect_push("Library", "file:///lib.png", "library!", "appid://fake/library/0.0", success);151 expect_push("Library", "file:///lib.png", "library!", "appid://fake-container/library/0.0", success);
109 }152 }
110153
111 void expect_push_linux(bool success = true)154 void expect_push_linux(bool success = true)
112 {155 {
113 expect_push("Linux", "file:///nix.png", "linux!", "appid://fake/linux/0.0", success);156 expect_push("Linux", "file:///nix.png", "linux!", "appid://fake-container/linux/0.0", success);
114 }157 }
115158
116 unity::scopes::SearchMetadata metadata;159 unity::scopes::SearchMetadata metadata;
@@ -118,10 +161,12 @@
118 testing::NiceMock<unity::scopes::testing::MockSearchReply> reply;161 testing::NiceMock<unity::scopes::testing::MockSearchReply> reply;
119 unity::scopes::SearchReplyProxy proxy;162 unity::scopes::SearchReplyProxy proxy;
120 std::shared_ptr<FakeCategory> category;163 std::shared_ptr<FakeCategory> category;
164 std::shared_ptr<MockHiddenApps> hidden;
165 std::shared_ptr<MockBlacklist> blacklist;
121};166};
122167
123168
124TEST_F(TestQueryFixture, returnsAllDisplayableAppsWithoutFilters)169TEST_F(TestQueryFixture, pushesAllDisplayableAppsWithoutFilters)
125{170{
126 expect_registry();171 expect_registry();
127 expect_push_libreoffice();172 expect_push_libreoffice();
@@ -130,12 +175,12 @@
130175
131 Query query(canned_query, metadata, []() {176 Query query(canned_query, metadata, []() {
132 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);177 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
133 });178 }, hidden, blacklist);
134 query.run(proxy);179 query.run(proxy);
135}180}
136181
137182
138TEST_F(TestQueryFixture, returnsRegularExpressionFilteredListOfApps)183TEST_F(TestQueryFixture, pushesRegularExpressionFilteredListOfApps)
139{184{
140 expect_registry();185 expect_registry();
141 expect_push_libreoffice();186 expect_push_libreoffice();
@@ -143,7 +188,7 @@
143188
144 Query query(canned_query, metadata, []() {189 Query query(canned_query, metadata, []() {
145 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);190 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
146 });191 }, hidden, blacklist);
147 query.run(proxy);192 query.run(proxy);
148}193}
149194
@@ -155,56 +200,90 @@
155200
156 Query query(canned_query, metadata, []() {201 Query query(canned_query, metadata, []() {
157 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);202 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
158 });203 }, hidden, blacklist);
159 query.run(proxy);204 query.run(proxy);
160}205}
161206
162207
163// Query class with faked out Settings208TEST_F(TestQueryFixture, ignoresBlacklistedApps)
164class QueryWithFakeSettings : public Query209{
165{210 expect_registry();
166public:211 expect_push_linux();
167 QueryWithFakeSettings(unity::scopes::CannedQuery const& query,212 expect_push_library();
168 unity::scopes::SearchMetadata const& metadata,213
169 Libertine::Factory const& libertine_factory)214 EXPECT_CALL(*blacklist, app_is_blacklisted(QString("libreoffice"), "fake-container"))
170 : Query(query, metadata, libertine_factory)215 .WillRepeatedly(testing::Return(true));
171 , settings_()216
172 {217 Query query(canned_query, metadata, []() {
173 }218 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
174219 }, hidden, blacklist);
175 unity::scopes::VariantMap settings() const override220 query.run(proxy);
176 {221}
177 return settings_;222
178 }223
179224TEST_F(TestQueryFixture, ignoresHiddenAppsInRootDepartment)
180 unity::scopes::VariantMap settings_;225{
181};226 expect_registry();
182227 expect_push_linux();
183228 expect_push_libreoffice();
184TEST_F(TestQueryFixture, ignoresAnyBlacklistedApps)229
185{230 EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library")))
186 expect_registry();231 .WillRepeatedly(testing::Return(true));
187 expect_push_library();232 EXPECT_CALL(*hidden, empty())
188233 .WillOnce(testing::Return(false));
189 QueryWithFakeSettings query(canned_query, metadata, []() {234
190 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);235 Query query(canned_query, metadata, []() {
191 });236 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
192 query.settings_["blacklist"] = "LibreOffice;Linux";237 }, hidden, blacklist);
193 query.run(proxy);238 query.run(proxy);
194}239}
195240
196241
197TEST_F(TestQueryFixture, stripsQuotationMarksFromBlacklist)242TEST_F(TestQueryFixture, ignoresNonHiddenAppsInHiddenDepartment)
198{243{
199 expect_registry();244 expect_registry();
200 expect_push_linux();245 expect_push_library();
201 expect_push_library();246
202247 EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library")))
203 QueryWithFakeSettings query(canned_query, metadata, []() {248 .WillRepeatedly(testing::Return(true));
204 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);249 EXPECT_CALL(*hidden, empty())
205 });250 .WillOnce(testing::Return(false));
206 query.settings_["blacklist"] = "\"LibreOffice\"";251
207 query.run(proxy);252 canned_query.set_department_id(HIDDEN_DEPT_ID);
208}253
209254 Query query(canned_query, metadata, []() {
255 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
256 }, hidden, blacklist);
257 query.run(proxy);
258}
259
260
261TEST_F(TestQueryFixture, showsHintWhenAllAppsFiltered)
262{
263 expect_registry();
264
265 EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category));
266 EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::ALL_RESULTS_FILTERED_HINT)))).WillOnce(testing::Return(true));
267
268 EXPECT_CALL(*hidden, app_is_hidden(testing::_)).WillRepeatedly(testing::Return(true));
269
270 Query query(canned_query, metadata, []() {
271 return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
272 }, hidden, blacklist);
273 query.run(proxy);
274}
275
276
277TEST_F(TestQueryFixture, showsHintWhenNoAppsInContainer)
278{
279 expect_registry();
280
281 EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category));
282 EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::NO_RESULTS_HINT)))).WillOnce(testing::Return(true));
283
284 Query query(canned_query, metadata, []() {
285 return FakeLibertine::make_fake("");
286 }, hidden, blacklist);
287 query.run(proxy);
288}
210} // anonymous namespace289} // anonymous namespace

Subscribers

People subscribed via source and target branches