#include "Window.hpp"
#include "Quickpanel.hpp"
-MenuItem::MenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType,
- VconfKeyType vconfStateKeysType, std::vector<std::string> vconfStateKeys,
- std::string subMenuLabel, std::string showingStateVconfKey)
+MenuItem::MenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType, std::string subMenuLabel, std::string showingStateVconfKey)
: names(std::move(names)), iconPath(std::move(iconPath)), activityType(std::move(activityType)),
- vconfStateKeysType(vconfStateKeysType), vconfStateKeys(std::move(vconfStateKeys)),
- subMenuLabel(std::move(subMenuLabel)), showingStateVconfKey(std::move(showingStateVconfKey)),
- quickpanelItem(false)
-{}
-
-MenuItem::MenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType, bool quickpanelItem)
- : names(std::move(names)), iconPath(std::move(iconPath)), activityType(std::move(activityType)),
- vconfStateKeysType(VconfKeyType::NONE), quickpanelItem(quickpanelItem)
-{}
+ subMenuLabel(std::move(subMenuLabel)), showingStateVconfKey(std::move(showingStateVconfKey)) {}
std::string MenuItem::getName() const
{
- if (names.empty())
- return {};
+ return names.empty() ? std::string() : gettext(names[0].c_str());
+}
- if (quickpanelItem) {
- /*
- * Using window will crash MenuBuilderTests
- * TODO solve in next patch
- **/
- auto window = Singleton<UniversalSwitch>::instance().getMainWindow();
- ASSERT(window, "NULL Window");
- return gettext(names[window->getQuickpanel()->isVisible() ? 1 : 0].c_str());
- }
+std::string MenuItem::getIconPath() const
+{
+ return iconPath;
+}
+
+std::string MenuItem::getActivityType() const
+{
+ return activityType;
+}
+
+VconfKeyType MenuItem::getVconfStateKeysType() const
+{
+ return VconfKeyType::NONE;
+}
+
+std::vector<std::string> MenuItem::getVconfStateKeys() const
+{
+ return {};
+}
+
+std::string MenuItem::getSubMenuLabel() const
+{
+ return subMenuLabel;
+}
+
+std::string MenuItem::getShowingStateVconfKey() const
+{
+ return showingStateVconfKey;
+}
+
+class VconfTypeMenuItem : public MenuItem
+{
+public:
+ VconfTypeMenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType,
+ VconfKeyType vconfStateKeysType, std::vector<std::string> vconfStateKeys,
+ std::string subMenuLabel = {}, std::string showingStateVconfKey = {});
+
+ std::string getName() const override;
+ VconfKeyType getVconfStateKeysType() const override;
+ std::vector<std::string> getVconfStateKeys() const override;
+
+private:
+ VconfKeyType vconfStateKeysType;
+ std::vector<std::string> vconfStateKeys;
+};
+
+class QuickpanelTypeMenuItem : public MenuItem
+{
+public:
+ QuickpanelTypeMenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType);
- if (vconfStateKeys.empty())
- return gettext(names[0].c_str());
+ std::string getName() const override;
+};
+VconfTypeMenuItem::VconfTypeMenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType,
+ VconfKeyType vconfStateKeysType, std::vector<std::string> vconfStateKeys,
+ std::string subMenuLabel, std::string showingStateVconfKey)
+ : MenuItem(std::move(names), std::move(iconPath), std::move(activityType), std::move(subMenuLabel), std::move(showingStateVconfKey)),
+ vconfStateKeysType(vconfStateKeysType), vconfStateKeys(std::move(vconfStateKeys))
+{
+ ASSERT(!VconfTypeMenuItem::names.empty() && !VconfTypeMenuItem::vconfStateKeys.empty(), "Forbidden VconfTypeMenuItem");
+}
+
+std::string VconfTypeMenuItem::getName() const
+{
switch (vconfStateKeysType) {
case VconfKeyType::BOOL: {
auto idx = 0;
return {};
}
-std::string MenuItem::getIconPath() const
-{
- return iconPath;
-}
-
-std::string MenuItem::getActivityType() const
-{
- return activityType;
-}
-
-VconfKeyType MenuItem::getVconfStateKeysType() const
+VconfKeyType VconfTypeMenuItem::getVconfStateKeysType() const
{
return vconfStateKeysType;
}
-std::vector<std::string> MenuItem::getVconfStateKeys() const
+std::vector<std::string> VconfTypeMenuItem::getVconfStateKeys() const
{
return vconfStateKeys;
}
-std::string MenuItem::getSubMenuLabel() const
-{
- return subMenuLabel;
-}
+QuickpanelTypeMenuItem::QuickpanelTypeMenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType)
+ : MenuItem(std::move(names), std::move(iconPath), std::move(activityType))
+{}
-std::string MenuItem::getShowingStateVconfKey() const
+std::string QuickpanelTypeMenuItem::getName() const
{
- return showingStateVconfKey;
+ auto window = Singleton<UniversalSwitch>::instance().getMainWindow();
+ ASSERT(window, "NULL Window");
+ return gettext(names[window->getQuickpanel()->isVisible() ? 1 : 0].c_str());
}
-
MenuMap::MenuMap()
{
const std::string defaultImg = ICONS_DIR "/tizen.png";
std::vector<std::string> {"IDS_HOME_SCREEN"},
defaultImg,
"START_HOME_SCREEN",
- VconfKeyType::NONE,
- std::vector<std::string> {},
std::string {},
VCONF_KEY_SHOW_HOME_SCREEN_MENU_ITEM);
auto back = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_BACK"},
defaultImg,
"BACK",
- VconfKeyType::NONE,
- std::vector<std::string> {},
std::string {},
VCONF_KEY_SHOW_BACK_MENU_ITEM);
- auto openCloseNotifications = std::make_shared<MenuItem>(
+ auto openCloseNotifications = std::make_shared<QuickpanelTypeMenuItem>(
std::vector<std::string> {"IDS_OPEN_NOTI_PANEL", "IDS_CLOSE_NOTI_PANEL"},
defaultImg,
- "TOGGLE_QUICKPANEL",
- true);
+ "TOGGLE_QUICKPANEL");
auto recentApps = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_RECENT_APPS"},
defaultImg,
"START_TASK_MGR",
- VconfKeyType::NONE,
- std::vector<std::string> {},
std::string {},
VCONF_KEY_SHOW_RECENT_APPS_MENU_ITEM);
auto accept = std::make_shared<MenuItem>(
auto selectAll = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_SELECT_ALL"},
defaultImg);
- auto previous = std::make_shared<MenuItem>(
+ auto previous = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> { "IDS_PREVIOUS_CHARACTER", "IDS_PREVIOUS_WORD", "IDS_PREVIOUS_LINE", "IDS_PREVIOUS_PARAGRAPH"},
defaultImg,
std::string {},/*TODO add activity*/
VconfKeyType::INT,
std::vector<std::string> {VCONF_KEY_GRANULARITY_UNIT});
- auto next = std::make_shared<MenuItem>(
+ auto next = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> { "IDS_NEXT_CHARACTER", "IDS_NEXT_WORD", "IDS_NEXT_LINE", "IDS_NEXT_PARAGRAPH"},
defaultImg,
std::string {},/*TODO add activity*/
std::vector<std::string> {"IDS_SWIPE_RIGHT"},
defaultImg,
"SWIPE_RIGHT");
- auto turnOnOffAutoScroll = std::make_shared<MenuItem>(
+ auto turnOnOffAutoScroll = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> {"IDS_TURN_ON_AUTO_SCROLL", "IDS_TURN_OFF_AUTO_SCROLL"},
defaultImg,
std::string {},/*TODO add activity*/
std::vector<std::string> {"IDS_ZOOM_OUT"},
defaultImg,
"ZOOM_OUT");
- auto soundVibrationMute = std::make_shared<MenuItem>(
+ auto soundVibrationMute = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> {"IDS_SOUND", "IDS_VIBRATION", "IDS_MUTE"},
defaultImg,
"CHANGE_SOUND_PROFILE_ACTIVITY",
std::vector<std::string> {"IDS_SLOW_DOWN_SCANING"},
defaultImg,
std::string{"SLOW_DOWN_AUTO_SCAN_ACTIVITY"});
- auto scanMethod = std::make_shared<MenuItem>(
+ auto scanMethod = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> {"IDS_ROW_SCAN", "IDS_POINT_SCAN"},
defaultImg,
std::string {"CHANGE_SCANNING_METHOD"},
VconfKeyType::INT,
std::vector<std::string> {VCONF_KEY_SCAN_METHOD});
- auto scanVerticalDirection = std::make_shared<MenuItem>(
+ auto scanVerticalDirection = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> {"IDS_BOTTOM_TO_TOP", "IDS_TOP_TO_BOTTOM"},
defaultImg,
std::string {}/*TODO add activity*/,
VconfKeyType::INT,
std::vector<std::string> {VCONF_KEY_SCAN_DIRECTION_VERTICAL});
- auto turnOnOffVoice = std::make_shared<MenuItem>(
+ auto turnOnOffVoice = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> {"IDS_TURN_ON_VOICE", "IDS_TURN_OFF_VOICE"},
defaultImg,
std::string {"TOGGLE_VOICE_FEEDBACK_ENABLED_ACTIVITY"},
VconfKeyType::BOOL,
std::vector<std::string> {VCONF_KEY_FEEDBACK_VOICE_ENABLED});
- auto turnOnOffSound = std::make_shared<MenuItem>(
+ auto turnOnOffSound = std::make_shared<VconfTypeMenuItem>(
std::vector<std::string> {"IDS_TURN_ON_SOUND", "IDS_TURN_OFF_SOUND"},
defaultImg,
std::string {"TOGGLE_SOUND_FEEDBACK_ENABLED_ACTIVITY"},
std::vector<std::string> {"IDS_AUTO_SCROLL"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_AUTO_SCROLL");
auto ScreenRotation = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_SCREEN_ROTATION"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_ROTATE_SCREEN");
auto gestures = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_GESTURES"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_GESTURES",
VCONF_KEY_SHOW_GESTURES_MENU_ITEM);
auto actions = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_ACTIONS"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_ACTIONS",
VCONF_KEY_SHOW_ACTIONS_MENU_ITEM);
auto settings = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_SETTINGS"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_SETTINGS",
VCONF_KEY_SHOW_SETTINGS_MENU_ITEM);
auto buttonsAndKeys = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_BUTTONS_AND_KEYS"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_BUTTONS_KEYS",
VCONF_KEY_SHOW_BUTTONS_AND_KEYS_MENU_ITEM);
auto editText = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_EDIT_TEXT"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_EDIT_TEXT");
auto granularitySettings = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_GRANULARITY_SETTINGS"},
defaultImg,
"SELECT",
- VconfKeyType::NONE,
- std::vector<std::string> {},
"IDS_MENU_GRANULARITY");
- auto emptyItem = std::make_shared<MenuItem>(
- std::vector<std::string> {},
- std::string {});
+ auto emptyItem = std::make_shared<MenuItem>();
addToMap("IDS_MENU_MAIN_NORMAL", {tap, gestures, actions, settings, recentApps, homeScreen, back, buttonsAndKeys});
#include "VConf.hpp"
#include "VConfKeys.hpp"
#include "MenuBuilder.hpp"
+#include "UniversalSwitch.hpp"
+#include "Singleton.hpp"
+#include "Window.hpp"
+#include "Quickpanel.hpp"
#include <gtest/gtest.h>
#include <string>
+#include <chrono>
+#include <thread>
#define VCONF_TESTS_PREFIX "accessibilityTests/"
"IDS_HOME_SCREEN", "IDS_BACK", "IDS_BUTTONS_AND_KEYS"
});
}
+
+ void testSoundProfile(const std::string &soundProfile)
+ {
+ testMenuContent("IDS_MENU_ACTIONS", {
+ "IDS_ZOOM_IN", "IDS_ZOOM_OUT", "IDS_SCREEN_ROTATION", soundProfile,
+ "IDS_LOCK", "IDS_OPEN_NOTI_PANEL", "IDS_CAPTURE_SCREENSHOT"
+ }, {
+ {}, {}, {}, {VCONF_KEY_SOUND_ENABLED, VCONF_KEY_VIBRATION_ENABLED}, {}, {}, {}
+ });
+ }
+
+ void testQuickpanel(const std::string &quickpanelState)
+ {
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ testMenuContent("IDS_MENU_ACTIONS", {
+ "IDS_ZOOM_IN", "IDS_ZOOM_OUT", "IDS_SCREEN_ROTATION", "IDS_SOUND",
+ "IDS_LOCK", quickpanelState, "IDS_CAPTURE_SCREENSHOT"
+ }, {
+ {}, {}, {}, {VCONF_KEY_SOUND_ENABLED, VCONF_KEY_VIBRATION_ENABLED}, {}, {}, {}
+ });
+ }
};
TEST_F(MenuBuilderTest, testContentOfMenuMainNormal)
TEST_F(MenuBuilderTest, testContentOfMenuActions)
{
- auto test = [this](std::string soundProfile) {
- this->testMenuContent("IDS_MENU_ACTIONS", {
- "IDS_ZOOM_IN", "IDS_ZOOM_OUT", "IDS_SCREEN_ROTATION", soundProfile,
- "IDS_LOCK", "IDS_OPEN_NOTI_PANEL", "IDS_CAPTURE_SCREENSHOT"
- }, {
- std::vector<std::string> {},
- std::vector<std::string> {},
- std::vector<std::string> {},
- std::vector<std::string> {VCONF_KEY_SOUND_ENABLED, VCONF_KEY_VIBRATION_ENABLED},
- std::vector<std::string> {},
- std::vector<std::string> {},
- std::vector<std::string> {}
- });
- };
-
setSoundProfileKeys("IDS_SOUND");
- test("IDS_VIBRATION");
+ testSoundProfile("IDS_VIBRATION");
setSoundProfileKeys("IDS_VIBRATION");
- test("IDS_MUTE");
+ testSoundProfile("IDS_MUTE");
setSoundProfileKeys("IDS_MUTE");
- test("IDS_SOUND");
+ testSoundProfile("IDS_SOUND");
+
+ Singleton<UniversalSwitch>::instance().getMainWindow()->getQuickpanel()->show();
+ testQuickpanel("IDS_CLOSE_NOTI_PANEL");
+ Singleton<UniversalSwitch>::instance().getMainWindow()->getQuickpanel()->hide();
+ testQuickpanel("IDS_OPEN_NOTI_PANEL");
}
TEST_F(MenuBuilderTest, testContentOfMenuRotateScreen)
EXPECT_EQ(prev->getName(), "IDS_PREVIOUS_" + requiredStates[ii]);
EXPECT_EQ(next->getName(), "IDS_NEXT_" + requiredStates[ii]);
}
-}
-
-TEST_F(MenuBuilderTest, testTranslations)
-{
- auto menuItem = Singleton<MenuMap>::instance().find("IDS_MENU_MAIN_NORMAL").back();
- EXPECT_EQ(menuItem->getName(), "IDS_TAP");
- bindtextdomain(PROJECT_NAME, LOCALE_DIR);
- textdomain(PROJECT_NAME);
- setlocale(LC_ALL, "en_US.UTF-8");
- EXPECT_EQ(menuItem->getName(), "Tap");
}
\ No newline at end of file