Back to index

unity  6.0.0
test_shortcut_private.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 <gtest/gtest.h>
00021 
00022 #include "ShortcutHintPrivate.h"
00023 
00024 using namespace unity::shortcut::impl;
00025 
00026 namespace {
00027 
00028 TEST(TestShortcutHintPrivate, TestFixShortcutFormatCorrect)
00029 {
00030   EXPECT_EQ(FixShortcutFormat("Super"), "Super");
00031   EXPECT_EQ(FixShortcutFormat("Super + A"), "Super + A");
00032 }
00033 
00034 
00035 TEST(TestShortcutHintPrivate, TestFixShortcutFormatLT)
00036 {
00037   EXPECT_EQ(FixShortcutFormat("<Super"), "Super");
00038   EXPECT_EQ(FixShortcutFormat("<Super + <Alt"), "Super + Alt");
00039 }
00040 
00041 TEST(TestShortcutHintPrivate, TestFixShortcutFormatGT)
00042 {
00043   EXPECT_EQ(FixShortcutFormat("Super>"), "Super");
00044   EXPECT_EQ(FixShortcutFormat("Super>A"), "Super + A");
00045   EXPECT_EQ(FixShortcutFormat("Super>Alt>A"), "Super + Alt + A");
00046 }
00047 
00048 TEST(TestShortcutHintPrivate, TestFixShortcutComplete)
00049 {
00050   EXPECT_EQ(FixShortcutFormat("Super"), "Super");
00051   EXPECT_EQ(FixShortcutFormat("Super + A"), "Super + A");
00052   EXPECT_EQ(FixShortcutFormat("<Super>"), "Super");
00053   EXPECT_EQ(FixShortcutFormat("<Super>A"), "Super + A");
00054   EXPECT_EQ(FixShortcutFormat("<Super><Alt>A"), "Super + Alt + A");
00055 }
00056 
00057 TEST(TestShortcutHintPrivate, TestProperCase)
00058 {
00059   EXPECT_EQ(ProperCase("super"), "Super");
00060   EXPECT_EQ(ProperCase("sUper"), "SUper");
00061   EXPECT_EQ(ProperCase("super + a"), "Super + A");
00062   EXPECT_EQ(ProperCase("super+a"), "Super+A");
00063   EXPECT_EQ(ProperCase("<super><alt>a"), "<Super><Alt>A");
00064 }
00065 
00066 TEST(TestShortcutHintPrivate, TestFixMouseShortcut)
00067 {
00068   EXPECT_EQ(FixMouseShortcut("Super<Button1>"), "Super<Left Mouse>");
00069   EXPECT_EQ(FixMouseShortcut("Super<Button2>"), "Super<Middle Mouse>");
00070   EXPECT_EQ(FixMouseShortcut("Super<Button3>"), "Super<Right Mouse>");
00071 }
00072 
00073 TEST(TestShortcutHintPrivate, TestGetMetaKey)
00074 {
00075   EXPECT_EQ(GetMetaKey("<Super>"), "<Super>");
00076   EXPECT_EQ(GetMetaKey("<Super><Alt>"), "<Super><Alt>");
00077   EXPECT_EQ(GetMetaKey("<Super>A"), "<Super>");
00078   EXPECT_EQ(GetMetaKey("<Super><Alt>A"), "<Super><Alt>");
00079   EXPECT_EQ(GetMetaKey("ABC"), "");
00080 }
00081 
00082 } // anonymouse namespace