2
* Copyright 2016 Canonical Ltd.
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.
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.
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/>.
16
#include "libertine-scope/blacklist.h"
17
#include <gtest/gtest.h>
19
#include <QTemporaryDir>
24
class TestBlacklistFixture : public ::testing::Test
27
TestBlacklistFixture()
28
: blacklist(QString("%1/data").arg(QDir::currentPath()).toStdString())
36
TEST_F(TestBlacklistFixture, ReturnsFalseWhenFileDoesNotExist)
38
EXPECT_FALSE(Blacklist(QTemporaryDir().path().toStdString()).app_is_blacklisted("app1", "container1"));
41
TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsNotInTheList)
43
EXPECT_FALSE(blacklist.app_is_blacklisted("app5", "container1"));
46
TEST_F(TestBlacklistFixture, ReturnsTrueWhenAppIsBlacklistedLocally)
48
EXPECT_TRUE(blacklist.app_is_blacklisted("app1", "container1"));
51
TEST_F(TestBlacklistFixture, ReturnsTrueWhenAppIsBlacklistedGlobally)
53
EXPECT_TRUE(blacklist.app_is_blacklisted("app2", "container2"));
56
TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsWhitelistedLocally)
58
EXPECT_FALSE(blacklist.app_is_blacklisted("app3", "container1"));
61
TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsWhitelistedGlobally)
63
EXPECT_FALSE(blacklist.app_is_blacklisted("app4", "container2"));