Back to index

unity  6.0.0
test_shortcut_model.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Andrea Azzarone <azzaronea@gmail.com>
00018  */
00019 
00020 #include <memory>
00021 #include <gtest/gtest.h>
00022 
00023 #include "MockShortcutHint.h"
00024 #include "ShortcutModel.h"
00025 
00026 using namespace unity::shortcut;
00027 
00028 namespace {
00029 
00030 TEST(TestShortcutModel, TestConstruction)
00031 {
00032   std::list<AbstractHint::Ptr> hints;
00033 
00034   hints.push_back(std::make_shared<MockHint>("Launcher", "", "", "Description 1", COMPIZ_KEY_OPTION, "Plugin 1", "key_option_1"));
00035   hints.push_back(std::make_shared<MockHint>("Launcher", "", "", "Description 2", HARDCODED_OPTION, "Value 2"));
00036   hints.push_back(std::make_shared<MockHint>("Dash", "Prefix", "Postfix", "Description 3", COMPIZ_KEY_OPTION, "Plugin 3", "key_option_3"));
00037   hints.push_back(std::make_shared<MockHint>("Menu Bar", "Prefix", "Postfix", "Description 4", HARDCODED_OPTION, "Value4"));
00038 
00039   Model model(hints);
00040 
00041   EXPECT_EQ(model.categories().size(), 3);
00042   EXPECT_EQ(model.hints()["Launcher"].size(), 2);
00043   EXPECT_EQ(model.hints()["Dash"].size(), 1);
00044   EXPECT_EQ(model.hints()["Menu Bar"].size(), 1);
00045   EXPECT_EQ(model.hints()["Unity"].size(), 0);
00046 }
00047 
00048 TEST(TestShortcutModel, TestFill)
00049 {
00050   std::list<AbstractHint::Ptr> hints;
00051 
00052   hints.push_back(std::make_shared<MockHint>("Launcher", "", "", "Description 1", COMPIZ_KEY_OPTION, "Plugin 1", "key_option_1"));
00053   hints.push_back(std::make_shared<MockHint>("Launcher", "", "", "Description 2", HARDCODED_OPTION, "Value 2"));
00054   hints.push_back(std::make_shared<MockHint>("Dash", "Prefix", "Postfix", "Description 3", COMPIZ_KEY_OPTION, "Plugin 3", "key_option_3"));
00055   hints.push_back(std::make_shared<MockHint>("Menu Bar", "Prefix", "Postfix", "Description 4", HARDCODED_OPTION, "Value 4"));
00056 
00057   Model model(hints);
00058 
00059   model.Fill();
00060 
00061   // We cannot test CompOption here... :/
00062   EXPECT_EQ(model.hints()["Launcher"].front()->value(), "Plugin 1-key_option_1");
00063   EXPECT_EQ(model.hints()["Launcher"].back()->value(), "Value 2");
00064   EXPECT_EQ(model.hints()["Dash"].front()->value(),"Plugin 3-key_option_3");
00065   EXPECT_EQ(model.hints()["Menu Bar"].front()->value(), "Value 4");
00066 }
00067 
00068 TEST(TestShortcutModel, TestProperty)
00069 {
00070   std::list<AbstractHint::Ptr> hints;
00071 
00072   hints.push_back(std::make_shared<MockHint>("Launcher", "Prefix1", "Postfix1", "Description1", COMPIZ_KEY_OPTION, "Plugin1", "key_option1"));
00073 
00074   Model model(hints);
00075 
00076   EXPECT_EQ(model.hints()["Launcher"].front()->category(), "Launcher");
00077   EXPECT_EQ(model.hints()["Launcher"].front()->prefix(), "Prefix1");
00078   EXPECT_EQ(model.hints()["Launcher"].front()->postfix(), "Postfix1");
00079   EXPECT_EQ(model.hints()["Launcher"].front()->description(), "Description1");
00080   EXPECT_EQ(model.hints()["Launcher"].front()->type(), COMPIZ_KEY_OPTION);
00081   EXPECT_EQ(model.hints()["Launcher"].front()->arg1(), "Plugin1");
00082   EXPECT_EQ(model.hints()["Launcher"].front()->arg2(), "key_option1");
00083 }
00084 
00085 } // anonymouse namespace