diff options
48 files changed, 1202 insertions, 1099 deletions
diff --git a/com.canonical.Unity.gschema.xml b/com.canonical.Unity.gschema.xml index 5e878af7e..5fffffe4b 100644 --- a/com.canonical.Unity.gschema.xml +++ b/com.canonical.Unity.gschema.xml @@ -46,7 +46,7 @@ <key type="as" name="favorites"> <default>[ 'application://ubiquity-gtkui.desktop', 'application://nautilus-home.desktop', 'application://firefox.desktop', 'application://libreoffice-writer.desktop', 'application://libreoffice-calc.desktop', 'application://libreoffice-impress.desktop', 'application://ubuntu-software-center.desktop', 'application://ubuntuone-installer.desktop', 'application://ubuntu-amazon-default.desktop', 'application://UbuntuOneMusiconeubuntucom.desktop', 'application://gnome-control-center.desktop', 'unity://running-apps', 'unity://expo-icon', 'unity://devices' ]</default> <summary>List of items that should be shown by default in the launcher</summary> - <description>These items can be application://desktop-id.desktop, device://uiid and unity://special-id (including unity://running-apps that specifies the position of the ran applications, unity://devices the position of the attached devices, unity://expo-icon the position of the workspace switcher and unity://show-desktop-icon the position of the show-desktop icon); the order of this list determines the launcher items position.</description> + <description>These items can be: application://desktop-id.desktop, device://uiid and unity://special-id (including: unity://running-apps (icons of running applications) unity://devices (icons of attached devices), unity://expo-icon (icon of the workspace switcher) and unity://desktop-icon (the show-desktop icon)); the order of this list determines the launcher item's position.</description> </key> <key type="s" name="favorite-migration"> <default>''</default> diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 360ef81d8..7969354fa 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -38,6 +38,7 @@ #include "unity-shared/PanelStyle.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UnitySettings.h" +#include "unity-shared/WindowManager.h" namespace unity { @@ -1592,15 +1593,15 @@ nux::Area* DashView::FindKeyFocusArea(unsigned int key_symbol, // Not sure if Enter should be a navigation key direction = KEY_NAV_ENTER; break; - case NUX_VK_F4: - // Maybe we should not do it here, but it needs to be checked where - // we are able to know if alt is pressed. - if (special_keys_state == NUX_STATE_ALT) + default: + auto const& close_key = WindowManager::Default().close_window_key(); + + if (close_key.first == special_keys_state && close_key.second == x11_key_code) { ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + return nullptr; } - break; - default: + direction = KEY_NAV_NONE; } diff --git a/debian/changelog b/debian/changelog index 011a10cc4..04860cb77 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,14 +1,66 @@ -unity (6.12.0daily13.01.25.1-0ubuntu2) UNRELEASED; urgency=low +unity (6.12.0daily13.02.04.1-0ubuntu1) raring; urgency=low * debian/control: - recommends indicator-sync so it gets installed by default (lp: #1053482) + - recommends indicator-bluetooth as well (lp: #1111314) [ Łukasz 'sil2100' Zemczak ] * debian/control: - bump compiz build-dep due to the last ABI break - -- Sebastien Bacher <seb128@ubuntu.com> Thu, 31 Jan 2013 11:39:19 +0100 + [ Brandon Schaefer ] + * [regression] Clicking on the indicators when the Dash is open no + longer closes the Dash. (LP: #1109150) + * [staging][raring] Dash Maximise/Restore button depends on the + launcher icon size. (LP: #1101310) + + [ Romain Perier ] + * The Dash closes when trying to switch to the Command lens (Alt+F2) + (LP: #1019457) + + [ Marco Trevisan (Treviño) ] + * Launcher can have smaller size on monitor resolution change (LP: + #1105382) + * Dragging down a window from the panel on an external monitor, + restores it at wrong offset (LP: #1104043) + * [regression] Alt+Tab/Alt+grave brings other window to the front but + loses focus entirely. (LP: #1111620) + * Quicklist items need a way to be ellipsized (LP: #1111471) + + [ Charles Kerr <charles.kerr@canonical.com>, Andrea Azzarone ] + * the GObject subclasses in tests/ don't dispose() properly (LP: + #986875) + + [ Nicolas d'Offay ] + * Speed up dash blur (LP: #1102410) + + [ Manuel de la Pena ] + * API changes to FindKeyFocusArea in the Preview class stops more + complicated previous fom setting the correct focus (LP: #1102387) + + [ MC Return ] + * Wrong description in Dconf key + com.canonical.unity.launcher.favorites (LP: #1112560) + * Keyboard shortcut overlay says Ctrl+Super+Down "minimises" the + current window, but it doesn't (LP: #966099) + + [ Andrea Azzarone ] + * unmounting any gvfs-mounted device from unity menu crashes compiz + (LP: #1111389) + * compiz crashed with SIGSEGV in async_wrapper_callback() from + g_simple_async_result_complete() from + _g_simple_async_result_complete_with_cancellable() from + unmount_reply() (LP: #1102926) + + [ Łukasz 'sil2100' Zemczak ] + * SwitcherControllerImpl autopilot test failures in unity - + 6.12.0daily13.01.29.2-0ubuntu1 (LP: #1109192) + + [ Automatic PS uploader ] + * Automatic snapshot from revision 3117 + + -- Automatic PS uploader <ps-jenkins@lists.canonical.com> Mon, 04 Feb 2013 09:59:13 +0000 unity (6.12.0daily13.01.25.1-0ubuntu1) raring; urgency=low diff --git a/debian/control b/debian/control index a69eb7c52..a0bbfb8cb 100644 --- a/debian/control +++ b/debian/control @@ -76,6 +76,7 @@ Recommends: gnome-control-center-unity, indicator-appmenu, indicator-application, indicator-sound, + indicator-bluetooth, indicator-datetime, indicator-messages, indicator-printers, diff --git a/hud/HudView.cpp b/hud/HudView.cpp index a5d91a571..e0c08c72a 100644 --- a/hud/HudView.cpp +++ b/hud/HudView.cpp @@ -32,6 +32,7 @@ #include "unity-shared/UBusMessages.h" #include "unity-shared/DashStyle.h" +#include "unity-shared/WindowManager.h" namespace unity { @@ -648,13 +649,15 @@ nux::Area* View::FindKeyFocusArea(unsigned int event_type, // Not sure if Enter should be a navigation key direction = nux::KEY_NAV_ENTER; break; - case NUX_VK_F4: - if (special_keys_state == nux::NUX_STATE_ALT) + default: + auto const& close_key = WindowManager::Default().close_window_key(); + + if (close_key.first == special_keys_state && close_key.second == x11_key_code) { ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); + return nullptr; } - break; - default: + direction = nux::KEY_NAV_NONE; break; } diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index 80144a04f..f4ae396bd 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -173,6 +173,31 @@ ApplicationLauncherIcon::~ApplicationLauncherIcon() } } +bool ApplicationLauncherIcon::GetQuirk(AbstractLauncherIcon::Quirk quirk) const +{ + if (quirk == Quirk::ACTIVE) + { + if (!SimpleLauncherIcon::GetQuirk(Quirk::ACTIVE)) + return false; + + if (app_->type() == "webapp") + return true; + + // Sometimes BAMF is not fast enough to update the active application + // while quickly switching between apps, so we double check that the + // real active window is part of the selection (see bug #1111620) + Window active = WindowManager::Default().GetActiveWindow(); + + for (auto& window : app_->GetWindows()) + if (window->window_id() == active) + return true; + + return false; + } + + return SimpleLauncherIcon::GetQuirk(quirk); +} + void ApplicationLauncherIcon::Remove() { /* Removing the unity-seen flag to the wrapped bamf application, on remove diff --git a/launcher/ApplicationLauncherIcon.h b/launcher/ApplicationLauncherIcon.h index f46e126a6..0a03f3e84 100644 --- a/launcher/ApplicationLauncherIcon.h +++ b/launcher/ApplicationLauncherIcon.h @@ -51,6 +51,8 @@ public: bool IsRunning() const; bool IsUrgent() const; + virtual bool GetQuirk(Quirk quirk) const; + virtual void Quit(); virtual void AboutToRemove(); diff --git a/launcher/SwitcherController.cpp b/launcher/SwitcherController.cpp index 6cbe798a7..fc9cd6807 100644 --- a/launcher/SwitcherController.cpp +++ b/launcher/SwitcherController.cpp @@ -547,17 +547,16 @@ Selection Controller::Impl::GetCurrentSelection() const if (model_) { application = model_->Selection(); + if (application) { if (model_->detail_selection) { window = model_->DetailSelectionWindow(); } - else if (application->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)) + else if (model_->SelectionIsActive()) { - auto const& xids = model_->DetailXids(); - if (!xids.empty()) - window = xids.front(); + window = model_->DetailXids().front(); } } } diff --git a/launcher/SwitcherModel.cpp b/launcher/SwitcherModel.cpp index 66c6ab9d3..afaec75fb 100644 --- a/launcher/SwitcherModel.cpp +++ b/launcher/SwitcherModel.cpp @@ -49,7 +49,7 @@ SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon::Ptr> const& icons SwitcherModel::~SwitcherModel() { - for (auto application : applications_) + for (auto const& application : applications_) { RemoveChild(application.GetPointer()); } @@ -71,69 +71,64 @@ void SwitcherModel::AddProperties(GVariantBuilder* builder) .add("last-selection-index", LastSelectionIndex()); } -SwitcherModel::iterator -SwitcherModel::begin() +SwitcherModel::iterator SwitcherModel::begin() { return applications_.begin(); } -SwitcherModel::iterator -SwitcherModel::end() +SwitcherModel::iterator SwitcherModel::end() { return applications_.end(); } -SwitcherModel::reverse_iterator -SwitcherModel::rbegin() +SwitcherModel::reverse_iterator SwitcherModel::rbegin() { return applications_.rbegin(); } -SwitcherModel::reverse_iterator -SwitcherModel::rend() +SwitcherModel::reverse_iterator SwitcherModel::rend() { return applications_.rend(); } -AbstractLauncherIcon::Ptr -SwitcherModel::at(unsigned int index) +AbstractLauncherIcon::Ptr SwitcherModel::at(unsigned int index) const { if ((int) index >= Size ()) return AbstractLauncherIcon::Ptr(); return applications_[index]; } -int -SwitcherModel::Size() +int SwitcherModel::Size() const { return applications_.size(); } -AbstractLauncherIcon::Ptr -SwitcherModel::Selection() +AbstractLauncherIcon::Ptr SwitcherModel::Selection() const { return applications_.at(index_); } -int -SwitcherModel::SelectionIndex() +int SwitcherModel::SelectionIndex() const { return index_; } -AbstractLauncherIcon::Ptr -SwitcherModel::LastSelection() +bool SwitcherModel::SelectionIsActive() const +{ + return Selection()->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE); +} + +AbstractLauncherIcon::Ptr SwitcherModel::LastSelection() const { return applications_.at(last_index_); } -int SwitcherModel::LastSelectionIndex() +int SwitcherModel::LastSelectionIndex() const { return last_index_; } - -std::vector<Window> SwitcherModel::DetailXids() +std::vector<Window> SwitcherModel::DetailXids() const { WindowManager& wm = WindowManager::Default(); std::vector<Window> results; @@ -159,7 +154,7 @@ std::vector<Window> SwitcherModel::DetailXids() return results; } -Window SwitcherModel::DetailSelectionWindow() +Window SwitcherModel::DetailSelectionWindow() const { auto windows = DetailXids(); if (!detail_selection || windows.empty()) @@ -209,7 +204,7 @@ void SwitcherModel::NextDetail() detail_selection_index = 0; } -void SwitcherModel::PrevDetail () +void SwitcherModel::PrevDetail() { if (!detail_selection()) return; @@ -242,8 +237,7 @@ void SwitcherModel::Select(AbstractLauncherIcon::Ptr const& selection) } } -void -SwitcherModel::Select(unsigned int index) +void SwitcherModel::Select(unsigned int index) { unsigned int target = CLAMP(index, 0, applications_.size() - 1); diff --git a/launcher/SwitcherModel.h b/launcher/SwitcherModel.h index 86e644cd5..2b2368e03 100644 --- a/launcher/SwitcherModel.h +++ b/launcher/SwitcherModel.h @@ -70,18 +70,19 @@ public: reverse_iterator rbegin(); reverse_iterator rend(); - launcher::AbstractLauncherIcon::Ptr at(unsigned int index); + launcher::AbstractLauncherIcon::Ptr at(unsigned int index) const; - int Size(); + int Size() const; - launcher::AbstractLauncherIcon::Ptr Selection(); - int SelectionIndex(); + launcher::AbstractLauncherIcon::Ptr Selection() const; + int SelectionIndex() const; + bool SelectionIsActive() const; - launcher::AbstractLauncherIcon::Ptr LastSelection(); - int LastSelectionIndex(); + launcher::AbstractLauncherIcon::Ptr LastSelection() const; + int LastSelectionIndex() const; - std::vector<Window> DetailXids (); - Window DetailSelectionWindow (); + std::vector<Window> DetailXids() const; + Window DetailSelectionWindow() const; void Next(); void Prev(); diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp index 5e963ad0a..d3416562e 100644 --- a/panel/PanelMenuView.cpp +++ b/panel/PanelMenuView.cpp @@ -80,25 +80,63 @@ PanelMenuView::PanelMenuView() , menus_discovery_fadein_(DEFAULT_DISCOVERY_FADEIN) , menus_discovery_fadeout_(DEFAULT_DISCOVERY_FADEOUT) { - layout_->SetContentDistribution(nux::MAJOR_POSITION_START); BamfWindow* active_win = bamf_matcher_get_active_window(matcher_); if (BAMF_IS_WINDOW(active_win)) active_xid_ = bamf_window_get_xid(active_win); - view_opened_signal_.Connect(matcher_, "view-opened", - sigc::mem_fun(this, &PanelMenuView::OnViewOpened)); - view_closed_signal_.Connect(matcher_, "view-closed", - sigc::mem_fun(this, &PanelMenuView::OnViewClosed)); + SetupPanelMenuViewSignals(); + SetupWindowButtons(); + SetupTitlebarGrabArea(); + SetupWindowManagerSignals(); + SetupUBusManagerInterests(); + + style_changed_connection_ = panel::Style::Instance().changed.connect([&] { + window_buttons_->ComputeContentSize(); + layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0); + + Refresh(true); + FullRedraw(); + }); + + opacity = 0.0f; + + Refresh(); + FullRedraw(); +} + +PanelMenuView::~PanelMenuView() +{ + style_changed_connection_.disconnect(); + window_buttons_->UnParentObject(); + titlebar_grab_area_->UnParentObject(); +} + +void PanelMenuView::SetupPanelMenuViewSignals() +{ active_win_changed_signal_.Connect(matcher_, "active-window-changed", sigc::mem_fun(this, &PanelMenuView::OnActiveWindowChanged)); active_app_changed_signal_.Connect(matcher_, "active-application-changed", sigc::mem_fun(this, &PanelMenuView::OnActiveAppChanged)); + view_opened_signal_.Connect(matcher_, "view-opened", + sigc::mem_fun(this, &PanelMenuView::OnViewOpened)); + view_closed_signal_.Connect(matcher_, "view-closed", + sigc::mem_fun(this, &PanelMenuView::OnViewClosed)); + + mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); + mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); + + opacity_animator_.updated.connect(sigc::mem_fun(this, &PanelMenuView::OnFadeAnimatorUpdated)); +} + +void PanelMenuView::SetupWindowButtons() +{ window_buttons_ = new WindowButtons(); window_buttons_->SetParentObject(this); window_buttons_->monitor = monitor_; window_buttons_->controlled_window = active_xid_; + window_buttons_->opacity = 0.0f; window_buttons_->SetLeftAndRightPadding(MAIN_LEFT_PADDING, MENUBAR_PADDING); window_buttons_->SetMaximumHeight(panel::Style::Instance().panel_height); window_buttons_->ComputeContentSize(); @@ -109,9 +147,18 @@ PanelMenuView::PanelMenuView() window_buttons_->opacity.changed.connect(sigc::hide(sigc::mem_fun(this, &PanelMenuView::QueueDraw))); AddChild(window_buttons_.GetPointer()); + SetupLayout(); +} + +void PanelMenuView::SetupLayout() +{ + layout_->SetContentDistribution(nux::MAJOR_POSITION_START); layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0); layout_->SetBaseHeight(panel::Style::Instance().panel_height); +} +void PanelMenuView::SetupTitlebarGrabArea() +{ titlebar_grab_area_ = new PanelTitlebarGrabArea(); titlebar_grab_area_->SetParentObject(this); titlebar_grab_area_->activate_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedActivate)); @@ -120,8 +167,13 @@ PanelMenuView::PanelMenuView() titlebar_grab_area_->grab_started.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabStart)); titlebar_grab_area_->grab_move.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabMove)); titlebar_grab_area_->grab_end.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd)); + titlebar_grab_area_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); + titlebar_grab_area_->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); AddChild(titlebar_grab_area_.GetPointer()); +} +void PanelMenuView::SetupWindowManagerSignals() +{ WindowManager& wm = WindowManager::Default(); wm.window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized)); wm.window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized)); @@ -138,43 +190,16 @@ PanelMenuView::PanelMenuView() wm.initiate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoInitiate)); wm.terminate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); +} - style_changed_connection_ = panel::Style::Instance().changed.connect([&] { - window_buttons_->ComputeContentSize(); - layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0); - - Refresh(true); - FullRedraw(); - }); - - mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); - mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); - //mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); - - titlebar_grab_area_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); - titlebar_grab_area_->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); - +void PanelMenuView::SetupUBusManagerInterests() +{ ubus_manager_.RegisterInterest(UBUS_SWITCHER_SHOWN, sigc::mem_fun(this, &PanelMenuView::OnSwitcherShown)); ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_NAV, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavStarted)); ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_NAV, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavEnded)); ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_SWITCHER, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavStarted)); ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWITCHER, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavEnded)); ubus_manager_.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, sigc::mem_fun(this, &PanelMenuView::OnLauncherSelectionChanged)); - - opacity_animator_.updated.connect(sigc::mem_fun(this, &PanelMenuView::OnFadeAnimatorUpdated)); - - opacity = 0.0f; - window_buttons_->opacity = 0.0f; - - Refresh(); - FullRedraw(); -} - -PanelMenuView::~PanelMenuView() -{ - style_changed_connection_.disconnect(); - window_buttons_->UnParentObject(); - titlebar_grab_area_->UnParentObject(); } void PanelMenuView::OverlayShown() @@ -234,12 +259,6 @@ nux::Area* PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, n Area* found_area = nullptr; - if (overlay_showing_) - { - if (window_buttons_) - return window_buttons_->FindAreaUnderMouse(mouse_position, event_type); - } - if (!we_control_active_) { /* When the current panel is not active, it all behaves like a grab-area */ @@ -256,7 +275,7 @@ nux::Area* PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, n } } - if (titlebar_grab_area_ && !overlay_showing_) + if (titlebar_grab_area_) { found_area = titlebar_grab_area_->FindAreaUnderMouse(mouse_position, event_type); NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area); @@ -338,7 +357,7 @@ bool PanelMenuView::ShouldDrawMenus() const WindowManager& wm = WindowManager::Default(); bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive()); - if (we_control_active_ && !overlay_showing_ && !screen_grabbed && + if (we_control_active_ && !screen_grabbed && !switcher_showing_ && !launcher_keynav_ && !entries_.empty()) { if (is_inside_ || last_active_view_ || show_now_activated_ || new_application_) @@ -355,10 +374,6 @@ bool PanelMenuView::ShouldDrawButtons() const WindowManager& wm = WindowManager::Default(); bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive()); - // TODO: We need to refactor this code to extract the window button logic - if (overlay_showing_) - return false; - if (we_control_active_ && is_maximized_ && !screen_grabbed && !launcher_keynav_ && !switcher_showing_) { @@ -428,6 +443,9 @@ void PanelMenuView::UpdateLastGeometry(nux::Geometry const& geo) void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { + if (overlay_showing_) + return; + nux::Geometry const& geo = GetGeometry(); UpdateLastGeometry(geo); @@ -466,7 +484,7 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) texxform1, nux::color::White); } - else if (!overlay_showing_) + else { double title_opacity = GetTitleOpacity(); @@ -584,6 +602,9 @@ void PanelMenuView::UpdateTitleGradientTexture() void PanelMenuView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { + if (overlay_showing_) + return; + nux::Geometry const& geo = GetGeometry(); bool draw_menus = ShouldDrawMenus(); bool draw_buttons = ShouldDrawButtons(); @@ -610,9 +631,9 @@ void PanelMenuView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw new_app_menu_shown_ = false; } } - else /* if (!draw_menus) */ + else { - if (opacity() != 0.0f && !overlay_showing_) + if (opacity() != 0.0f) { layout_->ProcessDraw(GfxContext, true); StartFadeOut(new_app_menu_shown_ ? menus_discovery_fadeout_ : -1); @@ -1378,9 +1399,6 @@ void PanelMenuView::OnMaximizedActivate(int x, int y) void PanelMenuView::OnMaximizedRestore(int x, int y) { - if (overlay_showing_) - return; - Window maximized = GetMaximizedWindow(); if (maximized != 0) @@ -1392,9 +1410,6 @@ void PanelMenuView::OnMaximizedRestore(int x, int y) void PanelMenuView::OnMaximizedLower(int x, int y) { - if (overlay_showing_) - return; - Window maximized = GetMaximizedWindow(); if (maximized != 0) diff --git a/panel/PanelMenuView.h b/panel/PanelMenuView.h index 82579612d..286af408a 100644 --- a/panel/PanelMenuView.h +++ b/panel/PanelMenuView.h @@ -73,6 +73,13 @@ protected: private: friend class TestPanelMenuView; + void SetupPanelMenuViewSignals(); + void SetupWindowButtons(); + void SetupLayout(); + void SetupTitlebarGrabArea(); + void SetupWindowManagerSignals(); + void SetupUBusManagerInterests(); + void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active); void OnViewOpened(BamfMatcher* matcher, BamfView* view); void OnViewClosed(BamfMatcher* matcher, BamfView* view); diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp index d4ca2481b..8e95eef9a 100644 --- a/panel/PanelView.cpp +++ b/panel/PanelView.cpp @@ -526,8 +526,11 @@ void PanelView::ForceUpdateBackground() UpdateBackground(); indicators_->QueueDraw(); - menu_view_->QueueDraw(); tray_->QueueDraw(); + + if (!overlay_is_open_) + menu_view_->QueueDraw(); + QueueDraw(); } diff --git a/po/POTFILES.in b/po/POTFILES.in index 3e92b2efb..801b82e6c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,7 +31,7 @@ plugins/unityshell/src/unityshell.cpp plugins/unityshell/unityshell.xml.in shortcuts/ShortcutHintPrivate.cpp shortcuts/ShortcutView.cpp -shortcuts/CompizShortcutsModeller.cpp +shortcuts/CompizShortcutModeller.cpp services/panel-service.c unity-shared/DashStyle.cpp unity-shared/SearchBar.cpp diff --git a/services/panel-service.c b/services/panel-service.c index e8468fb93..b23890d9d 100644 --- a/services/panel-service.c +++ b/services/panel-service.c @@ -108,7 +108,7 @@ static const gchar * indicator_order[][2] = { {"libapplication.so", "gsd-keyboard-xkb"}, /* keyboard layout selector */ {"libmessaging.so", NULL}, /* indicator-messages */ {"libpower.so", NULL}, /* indicator-power */ - {"libapplication.so", "bluetooth-manager"}, /* bluetooth manager */ + {"libbluetooth.so", NULL}, /* indicator-bluetooth */ {"libnetwork.so", NULL}, /* indicator-network */ {"libnetworkmenu.so", NULL}, /* indicator-network */ {"libapplication.so", "nm-applet"}, /* network manager */ diff --git a/shortcuts/CompizShortcutModeller.cpp b/shortcuts/CompizShortcutModeller.cpp index ac2527b56..b28c29cd7 100644 --- a/shortcuts/CompizShortcutModeller.cpp +++ b/shortcuts/CompizShortcutModeller.cpp @@ -42,7 +42,7 @@ namespace // Compiz Core Options const std::string CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key"; const std::string CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key"; - const std::string CORE_OPTION_UNMAXIMIZE_WINDOW_KEY = "unmaximize_window_key"; + const std::string CORE_OPTION_UNMAXIMIZE_OR_MINIMIZE_WINDOW_KEY = "unmaximize_or_minimize_window_key"; const std::string CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key"; const std::string CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key"; @@ -304,7 +304,7 @@ void CompizModeller::AddWindowsHints(std::list<shortcut::AbstractHint::Ptr> &hin _("Restores or minimises the current window."), shortcut::OptionType::COMPIZ_KEY, CORE_PLUGIN_NAME, - CORE_OPTION_UNMAXIMIZE_WINDOW_KEY)); + CORE_OPTION_UNMAXIMIZE_OR_MINIMIZE_WINDOW_KEY)); hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"), _("Semi-maximise the current window."), diff --git a/shortcuts/StandaloneShortcuts.cpp b/shortcuts/StandaloneShortcuts.cpp index 95b604a46..395bd27a3 100644 --- a/shortcuts/StandaloneShortcuts.cpp +++ b/shortcuts/StandaloneShortcuts.cpp @@ -226,7 +226,7 @@ struct StandaloneModeller : shortcut::AbstractModeller _("Restores or minimises the current window."), shortcut::OptionType::COMPIZ_KEY, "core", - "unmaximize_window_key"))); + "unmaximize_or_minimize_window_key"))); hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", _(" or Right"), _("Semi-maximises the current window."), diff --git a/tests/autopilot/unity/emulators/dash.py b/tests/autopilot/unity/emulators/dash.py index eaf4d472a..ee6c404b3 100644 --- a/tests/autopilot/unity/emulators/dash.py +++ b/tests/autopilot/unity/emulators/dash.py @@ -20,20 +20,23 @@ import dbus logger = logging.getLogger(__name__) -class Dash(KeybindingsHelper): - """ - An emulator class that makes it easier to interact with the unity dash. - """ +class DashController(UnityIntrospectionObject, KeybindingsHelper): + """The main dash controller object.""" + + def get_dash_view(self): + """Get the dash view that's attached to this controller.""" + return self.get_children_by_type(DashView)[0] - def __init__(self): - super(Dash, self).__init__() - controllers = DashController.get_all_instances() - assert(len(controllers) == 1) - self.controller = controllers[0] + def hide_dash_via_dbus(self): + """ Emulate a DBus call for dash hiding """ + dash_object = dbus.SessionBus().get_object('com.canonical.Unity', + '/com/canonical/Unity/Dash') + dash_iface = dbus.Interface(dash_object, 'com.canonical.Unity.Dash') + dash_iface.HideDash() @property def view(self): - return self.controller.get_dash_view() + return self.get_dash_view() def toggle_reveal(self): """ @@ -63,21 +66,6 @@ class Dash(KeybindingsHelper): self.visible.wait_for(False) @property - def visible(self): - """Returns if the dash is currently visible""" - return self.controller.visible - - @property - def monitor(self): - """The monitor where the dash is""" - return self.controller.monitor - - @property - def ideal_monitor(self): - """The ideal monitor for the dash to appear on""" - return self.controller.ideal_monitor - - @property def search_string(self): return self.searchbar.search_string @@ -157,21 +145,6 @@ class Dash(KeybindingsHelper): return (self.view.x, self.view.y, self.view.width, self.view.height) -class DashController(UnityIntrospectionObject): - """The main dash controller object.""" - - def get_dash_view(self): - """Get the dash view that's attached to this controller.""" - return self.get_children_by_type(DashView)[0] - - def hide_dash_via_dbus(self): - """ Emulate a DBus call for dash hiding """ - dash_object = dbus.SessionBus().get_object('com.canonical.Unity', - '/com/canonical/Unity/Dash') - dash_iface = dbus.Interface(dash_object, 'com.canonical.Unity.Dash') - dash_iface.HideDash() - - class DashView(UnityIntrospectionObject): """The dash view.""" diff --git a/tests/autopilot/unity/emulators/hud.py b/tests/autopilot/unity/emulators/hud.py index b43fb8c46..fa3fa8e1e 100644 --- a/tests/autopilot/unity/emulators/hud.py +++ b/tests/autopilot/unity/emulators/hud.py @@ -19,16 +19,17 @@ from unity.emulators.dash import SearchBar from unity.emulators.icons import HudEmbeddedIcon, HudLauncherIcon -class Hud(KeybindingsHelper): - """An emulator class that makes it easier to iteract with unity hud.""" - - def __init__(self): - super (Hud, self).__init__() - controllers = HudController.get_all_instances() - assert(len(controllers) == 1) - self.controller = controllers[0] +class HudController(UnityIntrospectionObject, KeybindingsHelper): + """Proxy object for the Unity Hud Controller.""" + + def __init__(self, *args, **kwargs): + super(HudController, self).__init__(*args, **kwargs) self.keyboard = Keyboard() + def get_hud_view(self): + views = self.get_children_by_type(HudView) + return views[0] if views else None + def ensure_hidden(self): """Hides the hud if it's not already hidden.""" if self.visible: @@ -77,17 +78,12 @@ class Hud(KeybindingsHelper): @property def view(self): """Returns the HudView.""" - return self.controller.get_hud_view() - - @property - def visible(self): - """Is the Hud visible?""" - return self.controller.visible + return self.get_hud_view() @property def searchbar(self): """Returns the searchbar attached to the hud.""" - return self.controller.get_hud_view().searchbar + return self.get_hud_view().searchbar @property def search_string(self): @@ -96,24 +92,19 @@ class Hud(KeybindingsHelper): @property def is_locked_launcher(self): - return self.controller.locked_to_launcher + return self.locked_to_launcher @property def monitor(self): - return self.controller.hud_monitor - - @property - def ideal_monitor(self): - """The target monitor for the Hud to appear on.""" - return self.controller.ideal_monitor + return self.hud_monitor @property def geometry(self): - return (self.controller.x, self.controller.y, self.controller.width, self.controller.height) + return (self.x, self.y, self.width, self.height) @property def selected_button(self): - view = self.controller.get_hud_view() + view = self.get_hud_view() if view: return view.selected_button else: @@ -134,7 +125,7 @@ class Hud(KeybindingsHelper): @property def num_buttons(self): - view = self.controller.get_hud_view() + view = self.get_hud_view() if view: return view.num_buttons else: @@ -158,13 +149,6 @@ class HudView(UnityIntrospectionObject): return (self.x, self.y, self.width, self.height) -class HudController(UnityIntrospectionObject): - """Proxy object for the Unity Hud Controller.""" - - def get_hud_view(self): - views = self.get_children_by_type(HudView) - return views[0] if views else None - class HudButton(UnityIntrospectionObject): """Proxy object for the hud buttons.""" diff --git a/tests/autopilot/unity/emulators/launcher.py b/tests/autopilot/unity/emulators/launcher.py index c7f00f571..636e986a3 100644 --- a/tests/autopilot/unity/emulators/launcher.py +++ b/tests/autopilot/unity/emulators/launcher.py @@ -51,7 +51,7 @@ class LauncherController(UnityIntrospectionObject): @property def model(self): """Return the launcher model.""" - models = LauncherModel.get_all_instances() + models = self.get_children_by_type(LauncherModel) assert(len(models) == 1) return models[0] diff --git a/tests/autopilot/unity/emulators/switcher.py b/tests/autopilot/unity/emulators/switcher.py index d675ecafb..af2809123 100644 --- a/tests/autopilot/unity/emulators/switcher.py +++ b/tests/autopilot/unity/emulators/switcher.py @@ -29,7 +29,13 @@ class SwitcherMode(): DETAIL = 2 -class Switcher(KeybindingsHelper): +class SwitcherDirection(): + """Directions the switcher can switch in.""" + FORWARDS = 0 + BACKWARDS = 1 + + +class SwitcherController(UnityIntrospectionObject, KeybindingsHelper): """A class for interacting with the switcher. Abstracts out switcher implementation, and makes the necessary functionality available @@ -37,29 +43,30 @@ class Switcher(KeybindingsHelper): """ - DIRECTION_FORWARDS = 0 - DIRECTION_BACKWARDS = 1 - - def __init__(self): - super(Switcher, self).__init__() + def __init__(self, *args, **kwargs): + super(SwitcherController, self).__init__(*args, **kwargs) self._mouse = Mouse() - controllers = SwitcherController.get_all_instances() - assert(len(controllers) == 1) - self.controller = controllers[0] + + def get_switcher_view(self): + views = self.get_children_by_type(SwitcherView) + return views[0] if views else None @property - def visible(self): - """Is the switcher currently visible + def view(self): + """Returns the SwitcherView.""" + return self.get_switcher_view() - """ - return self.controller.visible + @property + def model(self): + models = self.get_children_by_type(SwitcherModel) + return models[0] if models else None @property def icons(self): """The set of icons in the switcher model """ - return self.controller.model.icons + return self.model.icons @property def current_icon(self): @@ -69,28 +76,28 @@ class Switcher(KeybindingsHelper): @property def selection_index(self): """The index of the currently selected icon""" - return self.controller.model.selection_index + return self.model.selection_index @property def label(self): """The current switcher label""" - return self.controller.view.label + return self.view.label @property def label_visible(self): """The switcher label visibility""" - return self.controller.view.label_visible + return self.view.label_visible @property def mode(self): """Returns the SwitcherMode that the switcher is currently in.""" if not self.visible: return None - if self.controller.model.detail_selection and not self.controller.model.only_detail_on_viewport: + if self.model.detail_selection and not self.model.only_detail_on_viewport: return SwitcherMode.DETAIL, SwitcherMode.ALL - elif self.controller.model.detail_selection: + elif self.model.detail_selection: return SwitcherMode.DETAIL - elif not self.controller.model.only_detail_on_viewport: + elif not self.model.only_detail_on_viewport: return SwitcherMode.ALL else: return SwitcherMode.NORMAL @@ -108,7 +115,7 @@ class Switcher(KeybindingsHelper): elif mode == SwitcherMode.ALL: logger.debug("Initiating switcher in 'all workspaces' mode. Ctrl+Alt+Tab") self.keybinding_hold_part_then_tap("switcher/reveal_all") - self.controller.model.only_detail_on_viewport.wait_for(False) + self.model.only_detail_on_viewport.wait_for(False) def next_icon(self): """Move to the next icon.""" @@ -123,12 +130,12 @@ class Switcher(KeybindingsHelper): def select_icon(self, direction, **kwargs): """Select an icon in the switcher. - direction must be one of Switcher.DIRECTION_FORWARDS or Switcher.DIRECTION_BACKWARDS. + direction must be one of SwitcherDirection.FORWARDS or SwitcherDirection.BACKWARDS. The keyword arguments are used to select an icon. For example, you might do this to select the 'Show Desktop' icon: - >>> self.switcher.select_icon(Switcher.DIRECTION_BACKWARDS, tooltip_text="Show Desktop") + >>> self.switcher.select_icon(SwitcherDirection.BACKWARDS, tooltip_text="Show Desktop") The switcher must be initiated already, and must be in normal mode when this method is called, or a RuntimeError will be raised. @@ -139,10 +146,10 @@ class Switcher(KeybindingsHelper): if self.mode == SwitcherMode.DETAIL: raise RuntimeError("Switcher must be initiated in normal mode before calling this method.") - if direction not in (self.DIRECTION_BACKWARDS, self.DIRECTION_FORWARDS): - raise ValueError("direction must be one of Switcher.DIRECTION_BACKWARDS, Switcher.DIRECTION_FORWARDS") + if direction not in (SwitcherDirection.BACKWARDS, SwitcherDirection.FORWARDS): + raise ValueError("direction must be one of SwitcherDirection.BACKWARDS, SwitcherDirection.FORWARDS") - for i in self.controller.model.icons: + for i in self.model.icons: current_icon = self.current_icon passed=True for key,val in kwargs.iteritems(): @@ -150,9 +157,9 @@ class Switcher(KeybindingsHelper): passed=False if passed: return - if direction == self.DIRECTION_FORWARDS: + if direction == SwitcherDirection.FORWARDS: self.next_icon() - elif direction == self.DIRECTION_BACKWARDS: + elif direction == SwitcherDirection.BACKWARDS: self.previous_icon() raise ValueError("No icon found in switcher model that matches: %r" % kwargs) @@ -164,20 +171,20 @@ class Switcher(KeybindingsHelper): """ logger.debug("Cancelling switcher.") self.keybinding("switcher/cancel") - self.controller.visible.wait_for(False) + self.visible.wait_for(False) def terminate(self): """Stop switcher without activating the selected icon.""" logger.debug("Terminating switcher.") self.keybinding("switcher/cancel") self.keybinding_release("switcher/reveal_normal") - self.controller.visible.wait_for(False) + self.visible.wait_for(False) def select(self): """Stop switcher and activate the selected icon.""" logger.debug("Stopping switcher") self.keybinding_release("switcher/reveal_normal") - self.controller.visible.wait_for(False) + self.visible.wait_for(False) def next_via_mouse(self): """Move to the next icon using the mouse scroll wheel.""" @@ -194,24 +201,24 @@ class Switcher(KeybindingsHelper): @property def detail_selection_index(self): """The index of the currently selected detail""" - return self.controller.model.detail_selection_index + return self.model.detail_selection_index @property def detail_current_count(self): """The number of shown details""" - return self.controller.model.detail_current_count + return self.model.detail_current_count def show_details(self): """Show detail mode.""" logger.debug("Showing details view.") self.keybinding("switcher/detail_start") - self.controller.model.detail_selection.wait_for(True) + self.model.detail_selection.wait_for(True) def hide_details(self): """Hide detail mode.""" logger.debug("Hiding details view.") self.keybinding("switcher/detail_stop") - self.controller.model.detail_selection.wait_for(False) + self.model.detail_selection.wait_for(False) def next_detail(self): """Move to next detail in the switcher.""" @@ -224,18 +231,6 @@ class Switcher(KeybindingsHelper): self.keybinding("switcher/detail_prev") -class SwitcherController(UnityIntrospectionObject): - """An emulator class for interacting with the switcher controller.""" - - @property - def view(self): - return self.get_children_by_type(SwitcherView)[0] - - @property - def model(self): - return self.get_children_by_type(SwitcherModel)[0] - - class SwitcherView(UnityIntrospectionObject): """An emulator class for interacting with with SwitcherView.""" @@ -246,4 +241,3 @@ class SwitcherModel(UnityIntrospectionObject): @property def icons(self): return self.get_children_by_type(SimpleLauncherIcon) - diff --git a/tests/autopilot/unity/emulators/unity.py b/tests/autopilot/unity/emulators/unity.py index 6f0a31be9..22fdde19b 100644 --- a/tests/autopilot/unity/emulators/unity.py +++ b/tests/autopilot/unity/emulators/unity.py @@ -11,6 +11,17 @@ from __future__ import absolute_import from dbus import Interface, SessionBus +from unity.emulators import UnityIntrospectionObject +from unity.emulators.dash import DashController +from unity.emulators.hud import HudController +from unity.emulators.launcher import LauncherController +from unity.emulators.panel import PanelController +from unity.emulators.screen import Screen +from unity.emulators.shortcut_hint import ShortcutController +from unity.emulators.switcher import SwitcherController +from unity.emulators.window_manager import WindowManager + + # acquire the debugging dbus object UNITY_BUS_NAME = 'com.canonical.Unity' DEBUG_PATH = '/com/canonical/Unity/Debug' @@ -59,3 +70,37 @@ def log_unity_message(severity, message): """ get_dbus_logging_interface().LogMessage(severity, message) + +class Unity(UnityIntrospectionObject): + + @property + def screen(self): + return self.get_children_by_type(Screen)[0] + + @property + def dash(self): + return self.get_children_by_type(DashController)[0] + + @property + def hud(self): + return self.get_children_by_type(HudController)[0] + + @property + def launcher(self): + return self.get_children_by_type(LauncherController)[0] + + @property + def panels(self): + return self.get_children_by_type(PanelController)[0] + + @property + def switcher(self): + return self.get_children_by_type(SwitcherController)[0] + + @property + def shortcut_hint(self): + return self.get_children_by_type(ShortcutController)[0] + + @property + def window_manager(self): + return self.get_children_by_type(WindowManager)[0] diff --git a/tests/autopilot/unity/tests/__init__.py b/tests/autopilot/unity/tests/__init__.py index 164f8dba7..0d8d09c62 100644 --- a/tests/autopilot/unity/tests/__init__.py +++ b/tests/autopilot/unity/tests/__init__.py @@ -32,18 +32,12 @@ from testtools.matchers import Equals from unittest.case import SkipTest from unity.emulators import ensure_unity_is_running -from unity.emulators.screen import Screen -from unity.emulators.dash import Dash -from unity.emulators.hud import Hud -from unity.emulators.launcher import LauncherController -from unity.emulators.panel import PanelController -from unity.emulators.switcher import Switcher -from unity.emulators.window_manager import WindowManager from unity.emulators.workspace import WorkspaceManager from unity.emulators.unity import ( set_log_severity, start_log_to_file, reset_logging, + Unity ) @@ -53,9 +47,6 @@ log = getLogger(__name__) class UnityTestCase(AutopilotTestCase): """Unity test case base class, with improvments specific to Unity tests.""" - def __init__(self, *args): - super(UnityTestCase, self).__init__(*args) - def setUp(self): super(UnityTestCase, self).setUp() try: @@ -91,19 +82,19 @@ class UnityTestCase(AutopilotTestCase): log.warning("Test changed the active workspace, changing it back...") self.workspace.switch_to(self._initial_workspace_num) # Have we left the dash open? - if not self.well_behaved(self.dash, visible=False): + if not self.well_behaved(self.unity.dash, visible=False): well_behaved = False reasons.append("The test left the dash open.") log.warning("Test left the dash open, closing it...") - self.dash.ensure_hidden() + self.unity.dash.ensure_hidden() # ... or the hud? - if not self.well_behaved(self.hud, visible=False): + if not self.well_behaved(self.unity.hud, visible=False): well_behaved = False reasons.append("The test left the hud open.") log.warning("Test left the hud open, closing it...") self.hud.ensure_hidden() # Are we in show desktop mode? - if not self.well_behaved(self.window_manager, showdesktop_active=False): + if not self.well_behaved(self.unity.window_manager, showdesktop_active=False): well_behaved = False reasons.append("The test left the system in show_desktop mode.") log.warning("Test left the system in show desktop mode, exiting it...") @@ -116,15 +107,15 @@ class UnityTestCase(AutopilotTestCase): # exception. win = self.start_app_window('Calculator', locale='C') count = 1 - while self.window_manager.showdesktop_active: + while self.unity.window_manager.showdesktop_active: self.keybinding("window/show_desktop") sleep(count) count+=1 if count > 10: break win.close() - self.window_manager.showdesktop_active.wait_for(False) - for launcher in self.launcher.get_launchers(): + self.unity.window_manager.showdesktop_active.wait_for(False) + for launcher in self.unity.launcher.get_launchers(): if not self.well_behaved(launcher, in_keynav_mode=False): well_behaved = False reasons.append("The test left the launcher keynav mode enabled.") @@ -154,46 +145,8 @@ class UnityTestCase(AutopilotTestCase): return True @property - def screen(self): - if not getattr(self, '__screen', None): - self.__screen = self._get_screen() - return self.__screen - - @property - def dash(self): - if not getattr(self, '__dash', None): - self.__dash = Dash() - return self.__dash - - @property - def hud(self): - if not getattr(self, '__hud', None): - self.__hud = Hud(); - return self.__hud - - @property - def launcher(self): - if not getattr(self, '__launcher', None): - self.__launcher = self._get_launcher_controller() - return self.__launcher - - @property - def panels(self): - if not getattr(self, '__panels', None): - self.__panels = self._get_panel_controller() - return self.__panels - - @property - def switcher(self): - if not getattr(self, '__switcher', None): - self.__switcher = Switcher() - return self.__switcher - - @property - def window_manager(self): - if not getattr(self, '__window_manager', None): - self.__window_manager = self._get_window_manager() - return self.__window_manager + def unity(self): + return Unity.get_root_instance() @property def workspace(self): @@ -201,26 +154,6 @@ class UnityTestCase(AutopilotTestCase): self.__workspace = WorkspaceManager() return self.__workspace - def _get_screen(self): - screens = Screen.get_all_instances() - self.assertThat(len(screens), Equals(1)) - return screens[0] - - def _get_launcher_controller(self): - controllers = LauncherController.get_all_instances() - self.assertThat(len(controllers), Equals(1)) - return controllers[0] - - def _get_panel_controller(self): - controllers = PanelController.get_all_instances() - self.assertThat(len(controllers), Equals(1)) - return controllers[0] - - def _get_window_manager(self): - managers = WindowManager.get_all_instances() - self.assertThat(len(managers), Equals(1)) - return managers[0] - def _setUpUnityLogging(self): self._unity_log_file_name = mktemp(prefix=self.shortDescription()) start_log_to_file(self._unity_log_file_name) diff --git a/tests/autopilot/unity/tests/launcher/__init__.py b/tests/autopilot/unity/tests/launcher/__init__.py index 8f7602d92..4d659c128 100644 --- a/tests/autopilot/unity/tests/launcher/__init__.py +++ b/tests/autopilot/unity/tests/launcher/__init__.py @@ -56,4 +56,4 @@ class LauncherTestCase(UnityTestCase): def get_launcher(self): """Get the launcher for the current scenario.""" - return self.launcher.get_launcher_for_monitor(self.launcher_monitor) + return self.unity.launcher.get_launcher_for_monitor(self.launcher_monitor) diff --git a/tests/autopilot/unity/tests/launcher/test_capture.py b/tests/autopilot/unity/tests/launcher/test_capture.py index 6783301bf..844cd6721 100644 --- a/tests/autopilot/unity/tests/launcher/test_capture.py +++ b/tests/autopilot/unity/tests/launcher/test_capture.py @@ -37,7 +37,7 @@ class LauncherCaptureTests(UnityTestCase): def setHideMode(self, mode): self.set_unity_option('launcher_hide_mode', mode) - launcher = self.launcher.get_launcher_for_monitor(0) + launcher = self.unity.launcher.get_launcher_for_monitor(0) self.assertThat(launcher.hidemode, Eventually(Equals(mode))) def leftMostMonitor(self): diff --git a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py index d8ebdff93..56e231b57 100644 --- a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py +++ b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py @@ -45,7 +45,7 @@ class LauncherIconsTests(LauncherTestCase): self.addCleanup(self.call_gsettings_cmd, 'set', 'com.canonical.Unity.Launcher', 'favorites', old_fav) self.call_gsettings_cmd('set', 'com.canonical.Unity.Launcher', 'favorites', new_fav) - icon = self.launcher.model.get_children_by_type(ExpoLauncherIcon)[0] + icon = self.unity.launcher.model.get_children_by_type(ExpoLauncherIcon)[0] self.assertThat(icon, NotEquals(None)) self.assertThat(icon.visible, Eventually(Equals(True))) @@ -53,7 +53,7 @@ class LauncherIconsTests(LauncherTestCase): def ensure_calculator_in_launcher_and_not_running(self): calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) + calc_icon = self.unity.launcher.model.get_icon(desktop_id=calc.desktop_file) self.addCleanup(self.launcher_instance.unlock_from_launcher, calc_icon) self.launcher_instance.lock_to_launcher(calc_icon) self.close_all_app("Calculator") @@ -67,21 +67,21 @@ class LauncherIconsTests(LauncherTestCase): def test_bfb_tooltip_disappear_when_dash_is_opened(self): """Tests that the bfb tooltip disappear when the dash is opened.""" - bfb = self.launcher.model.get_bfb_icon() + bfb = self.unity.launcher.model.get_bfb_icon() self.mouse.move(bfb.center_x, bfb.center_y) self.assertThat(bfb.get_tooltip().active, Eventually(Equals(True))) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.assertThat(bfb.get_tooltip().active, Eventually(Equals(False))) def test_bfb_tooltip_is_disabled_when_dash_is_open(self): """Tests the that bfb tooltip is disabled when the dash is open.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) - bfb = self.launcher.model.get_bfb_icon() + bfb = self.unity.launcher.model.get_bfb_icon() self.mouse.move(bfb.center_x, bfb.center_y) # Tooltips are lazy-created in Unity, so if the BFB tooltip has never @@ -94,8 +94,8 @@ class LauncherIconsTests(LauncherTestCase): def test_shift_click_opens_new_application_instance(self): """Shift+Clicking MUST open a new instance of an already-running application.""" app = self.start_app("Calculator") - icon = self.launcher.model.get_icon(desktop_id=app.desktop_file) - launcher_instance = self.launcher.get_launcher_for_monitor(0) + icon = self.unity.launcher.model.get_icon(desktop_id=app.desktop_file) + launcher_instance = self.unity.launcher.get_launcher_for_monitor(0) self.keyboard.press("Shift") self.addCleanup(self.keyboard.release, "Shift") @@ -114,9 +114,9 @@ class LauncherIconsTests(LauncherTestCase): self.assertVisibleWindowStack([char_win2, calc_win, char_win1]) - char_icon = self.launcher.model.get_icon( + char_icon = self.unity.launcher.model.get_icon( desktop_id=char_win2.application.desktop_file) - calc_icon = self.launcher.model.get_icon( + calc_icon = self.unity.launcher.model.get_icon( desktop_id=calc_win.application.desktop_file) self.launcher_instance.click_launcher_icon(calc_icon) @@ -160,12 +160,12 @@ class LauncherIconsTests(LauncherTestCase): self.assertVisibleWindowStack([char_win2, char_win1]) self.assertProperty(char_win2, is_focused=True) - char_icon = self.launcher.model.get_icon(desktop_id=char_app.desktop_file) + char_icon = self.unity.launcher.model.get_icon(desktop_id=char_app.desktop_file) self.addCleanup(self.keybinding, "spread/cancel") self.launcher_instance.click_launcher_icon(char_icon) - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) - self.assertThat(self.window_manager.scale_active_for_group, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active_for_group, Eventually(Equals(True))) def test_while_in_scale_mode_the_dash_will_still_open(self): """If scale is initiated through the laucher pressing super must close @@ -178,28 +178,28 @@ class LauncherIconsTests(LauncherTestCase): self.assertVisibleWindowStack([char_win2, char_win1]) self.assertProperty(char_win2, is_focused=True) - char_icon = self.launcher.model.get_icon(desktop_id=char_app.desktop_file) + char_icon = self.unity.launcher.model.get_icon(desktop_id=char_app.desktop_file) self.launcher_instance.click_launcher_icon(char_icon) - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) - self.assertThat(self.dash.visible, Eventually(Equals(True))) - self.assertThat(self.window_manager.scale_active, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(False))) def test_icon_shows_on_quick_application_reopen(self): """Icons must stay on launcher when an application is quickly closed/reopened.""" calc = self.start_app("Calculator") desktop_file = calc.desktop_file - calc_icon = self.launcher.model.get_icon(desktop_id=desktop_file) + calc_icon = self.unity.launcher.model.get_icon(desktop_id=desktop_file) self.assertThat(calc_icon.visible, Eventually(Equals(True))) self.close_all_app("Calculator") calc = self.start_app("Calculator") sleep(2) - calc_icon = self.launcher.model.get_icon(desktop_id=desktop_file) + calc_icon = self.unity.launcher.model.get_icon(desktop_id=desktop_file) self.assertThat(calc_icon, NotEquals(None)) self.assertThat(calc_icon.visible, Eventually(Equals(True))) @@ -212,15 +212,15 @@ class LauncherIconsTests(LauncherTestCase): self.skipTest("This test requires enabled workspaces.") self.keybinding("expo/start") - self.assertThat(self.window_manager.expo_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.expo_active, Eventually(Equals(True))) self.addCleanup(self.keybinding, "expo/cancel") - bfb = self.launcher.model.get_bfb_icon() + bfb = self.unity.launcher.model.get_bfb_icon() self.mouse.move(bfb.center_x, bfb.center_y) self.mouse.click(button=3) self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(True))) - self.assertThat(self.window_manager.expo_active, Eventually(Equals(False))) + self.assertThat(self.unity.window_manager.expo_active, Eventually(Equals(False))) def test_expo_launcher_icon_initiates_expo(self): """Clicking on the expo launcher icon must start the expo.""" @@ -231,7 +231,7 @@ class LauncherIconsTests(LauncherTestCase): self.addCleanup(self.keybinding, "expo/cancel") self.launcher_instance.click_launcher_icon(expo) - self.assertThat(self.window_manager.expo_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.expo_active, Eventually(Equals(True))) def test_expo_launcher_icon_terminates_expo(self): """Clicking on the expo launcher icon when expo is active must close it.""" @@ -239,13 +239,13 @@ class LauncherIconsTests(LauncherTestCase): self.skipTest("This test requires enabled workspaces.") self.keybinding("expo/start") - self.assertThat(self.window_manager.expo_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.expo_active, Eventually(Equals(True))) self.addCleanup(self.keybinding, "expo/cancel") expo = self.ensure_expo_launcher_icon() self.launcher_instance.click_launcher_icon(expo) - self.assertThat(self.window_manager.expo_active, Eventually(Equals(False))) + self.assertThat(self.unity.window_manager.expo_active, Eventually(Equals(False))) def test_unminimize_initially_minimized_windows(self): """Make sure initially minimized windows can be unminimized.""" @@ -255,7 +255,7 @@ class LauncherIconsTests(LauncherTestCase): } window = self.launch_test_window(window_spec) - icon = self.launcher.model.get_icon(desktop_id=window.application.desktop_file) + icon = self.unity.launcher.model.get_icon(desktop_id=window.application.desktop_file) self.launcher_instance.click_launcher_icon(icon) self.assertThat(lambda: window.x_win.get_wm_state()['state'], Eventually(Equals(Xutil.NormalState))) @@ -268,7 +268,7 @@ class LauncherIconsTests(LauncherTestCase): } window = self.launch_test_window(window_spec) - icon = self.launcher.model.get_icon(desktop_id=window.application.desktop_file) + icon = self.unity.launcher.model.get_icon(desktop_id=window.application.desktop_file) self.launcher_instance.click_launcher_icon(icon) self.assertThat(lambda: window.x_win.get_wm_state()['state'], Eventually(Equals(Xutil.NormalState))) @@ -291,7 +291,7 @@ class LauncherDragIconsBehavior(LauncherTestCase): # Normally we'd use get_icon(desktop_id="...") but we're expecting it to # not exist, and we don't want to wait for 10 seconds, so we do this # the old fashioned way. - get_icon_fn = lambda: self.launcher.model.get_children_by_type( + get_icon_fn = lambda: self.unity.launcher.model.get_children_by_type( ApplicationLauncherIcon, desktop_id="gcalctool.desktop") calc_icon = get_icon_fn() if calc_icon: @@ -304,15 +304,15 @@ class LauncherDragIconsBehavior(LauncherTestCase): self.ensure_calc_icon_not_in_launcher() calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) - bfb_icon = self.launcher.model.get_bfb_icon() + calc_icon = self.unity.launcher.model.get_icon(desktop_id=calc.desktop_file) + bfb_icon = self.unity.launcher.model.get_bfb_icon() self.launcher_instance.drag_icon_to_position( calc_icon, IconDragType.AFTER, bfb_icon, self.drag_type) - moved_icon = self.launcher.model.\ + moved_icon = self.unity.launcher.model.\ get_launcher_icons_for_monitor(self.launcher_monitor)[1] self.assertThat(moved_icon.id, Equals(calc_icon.id)) @@ -321,9 +321,9 @@ class LauncherDragIconsBehavior(LauncherTestCase): self.ensure_calc_icon_not_in_launcher() calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) - bfb_icon = self.launcher.model.get_bfb_icon() - trash_icon = self.launcher.model.get_trash_icon() + calc_icon = self.unity.launcher.model.get_icon(desktop_id=calc.desktop_file) + bfb_icon = self.unity.launcher.model.get_bfb_icon() + trash_icon = self.unity.launcher.model.get_trash_icon() # Move a known icon to the top as it needs to be more than 2 icon # spaces away for this test to actually do anything @@ -341,7 +341,7 @@ class LauncherDragIconsBehavior(LauncherTestCase): self.drag_type) # Must be the last bamf icon - not necessarily the third-from-end icon. - refresh_fn = lambda: self.launcher.model.get_launcher_icons()[-2].id + refresh_fn = lambda: self.unity.launcher.model.get_launcher_icons()[-2].id self.assertThat(refresh_fn, Eventually(Equals(calc_icon.id)), - "Launcher icons are: %r" % self.launcher.model.get_launcher_icons()) + "Launcher icons are: %r" % self.unity.launcher.model.get_launcher_icons()) diff --git a/tests/autopilot/unity/tests/launcher/test_keynav.py b/tests/autopilot/unity/tests/launcher/test_keynav.py index 69b0e5ac7..1836bbe91 100644 --- a/tests/autopilot/unity/tests/launcher/test_keynav.py +++ b/tests/autopilot/unity/tests/launcher/test_keynav.py @@ -33,21 +33,21 @@ class LauncherKeyNavTests(LauncherTestCase): def safe_quit_keynav(self): """Quit the keynav mode if it's engaged.""" - if self.launcher.key_nav_is_active: + if self.unity.launcher.key_nav_is_active: self.launcher_instance.key_nav_cancel() def test_launcher_keynav_initiate(self): """Tests we can initiate keyboard navigation on the launcher.""" self.start_keynav_with_cleanup_cancel() - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True))) - self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_grabbed, Eventually(Equals(True))) def test_launcher_keynav_cancel(self): """Test that we can exit keynav mode.""" self.launcher_instance.key_nav_start() self.launcher_instance.key_nav_cancel() - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) - self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_grabbed, Eventually(Equals(False))) def test_launcher_keynav_cancel_resume_focus(self): """Test that ending the launcher keynav resume the focus.""" @@ -63,7 +63,7 @@ class LauncherKeyNavTests(LauncherTestCase): def test_launcher_keynav_starts_at_index_zero(self): """Test keynav mode starts at index 0.""" self.start_keynav_with_cleanup_cancel() - self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(Equals(0))) def test_launcher_keynav_forward(self): """Must be able to move forwards while in keynav mode.""" @@ -75,37 +75,37 @@ class LauncherKeyNavTests(LauncherTestCase): # make sure that the index has increased. This opens us to the # possibility that the launcher really is skipping forward more than one # icon at a time, but we can't do much about that. - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(0))) def test_launcher_keynav_prev_works(self): """Must be able to move backwards while in keynav mode.""" self.start_keynav_with_cleanup_cancel() self.launcher_instance.key_nav_next() - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(0))) self.launcher_instance.key_nav_prev() - self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(Equals(0))) def test_launcher_keynav_cycling_forward(self): """Launcher keynav must loop through icons when cycling forwards""" self.start_keynav_with_cleanup_cancel() prev_icon = 0 - for icon in range(1, self.launcher.model.num_launcher_icons()): + for icon in range(1, self.unity.launcher.model.num_launcher_icons()): self.launcher_instance.key_nav_next() # FIXME We can't directly check for selection/icon number equalty # since the launcher model also contains "hidden" icons that aren't # shown, so the selection index can increment by more than 1. - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon))) - prev_icon = self.launcher.key_nav_selection + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon))) + prev_icon = self.unity.launcher.key_nav_selection self.launcher_instance.key_nav_next() - self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(Equals(0))) def test_launcher_keynav_cycling_backward(self): """Launcher keynav must loop through icons when cycling backwards""" self.start_keynav_with_cleanup_cancel() self.launcher_instance.key_nav_prev() - # FIXME We can't directly check for self.launcher.num_launcher_icons - 1 - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(1))) + # FIXME We can't directly check for self.unity.launcher.num_launcher_icons - 1 + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(1))) def test_launcher_keynav_can_open_and_close_quicklist(self): """Tests that we can open and close a quicklist from keynav mode.""" @@ -115,15 +115,15 @@ class LauncherKeyNavTests(LauncherTestCase): self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(True))) self.launcher_instance.key_nav_exit_quicklist() self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(False))) - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True))) - self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_grabbed, Eventually(Equals(True))) def test_launcher_keynav_mode_toggles(self): """Tests that keynav mode toggles with Alt+F1.""" # was initiated in setup. self.start_keynav_with_cleanup_cancel() self.keybinding("launcher/keynav") - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_keynav_activate_keep_focus(self): """Activating a running launcher icon must focus it.""" @@ -151,59 +151,58 @@ class LauncherKeyNavTests(LauncherTestCase): self.launcher_instance.key_nav_activate() self.addCleanup(self.keybinding, "expo/cancel") - self.assertThat(self.panels.get_active_panel().title, Eventually(Equals("Ubuntu Desktop"))) + self.assertThat(self.unity.panels.get_active_panel().title, Eventually(Equals("Ubuntu Desktop"))) def test_launcher_keynav_expo_exit_on_esc(self): """Esc should quit expo when entering it from KeyNav.""" if self.workspace.num_workspaces < 2: self.skipTest("This test requires enabled more than one workspace.") - self.start_keynav_with_cleanup_cancel() self.launcher_instance.keyboard_select_icon(tooltip_text="Workspace Switcher") self.launcher_instance.key_nav_activate() self.keyboard.press_and_release("Escape") - self.assertThat(self.window_manager.expo_active, Eventually(Equals(False))) + self.assertThat(self.unity.window_manager.expo_active, Eventually(Equals(False))) def test_launcher_keynav_alt_tab_quits(self): """Tests that alt+tab exits keynav mode.""" self.start_keynav_with_cleanup_cancel() self.keybinding("switcher/reveal_normal") - self.addCleanup(self.switcher.terminate) - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.addCleanup(self.unity.switcher.terminate) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_keynav_alt_grave_quits(self): """Tests that alt+` exits keynav mode.""" self.start_keynav_with_cleanup_cancel() # Can't use switcher emulat here since the switcher won't appear. self.keybinding("switcher/reveal_details") - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_keynav_cancel_doesnt_activate_icon(self): """This tests when canceling keynav the current icon doesnt activate.""" self.start_keynav_with_cleanup_cancel() self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_alt_f1_closes_dash(self): """Pressing Alt+F1 when the Dash is open must close the Dash and start keynav.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.start_keynav_with_cleanup_cancel() - self.assertThat(self.dash.visible, Equals(False)) - self.assertThat(self.launcher.key_nav_is_active, Equals(True)) + self.assertThat(self.unity.dash.visible, Equals(False)) + self.assertThat(self.unity.launcher.key_nav_is_active, Equals(True)) def test_alt_f1_closes_hud(self): """Pressing Alt+F1 when the HUD is open must close the HUD and start keynav.""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.start_keynav_with_cleanup_cancel() - self.assertThat(self.hud.visible, Equals(False)) - self.assertThat(self.launcher.key_nav_is_active, Equals(True)) + self.assertThat(self.unity.hud.visible, Equals(False)) + self.assertThat(self.unity.launcher.key_nav_is_active, Equals(True)) def test_launcher_keynav_cancel_on_click_outside(self): """A single click outside of launcher must cancel keynav.""" @@ -212,36 +211,36 @@ class LauncherKeyNavTests(LauncherTestCase): self.launcher_instance.move_mouse_to_right_of_launcher() self.mouse.click() - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_keynav_cancel_on_click_icon(self): """A single click on a launcher icon must cancel keynav.""" calc_win = self.start_app_window('Calculator', locale = 'C') calc_app = calc_win.application - calc_icon = self.launcher.model.get_icon(desktop_id=calc_app.desktop_file) + calc_icon = self.unity.launcher.model.get_icon(desktop_id=calc_app.desktop_file) self.start_keynav_with_cleanup_cancel() self.launcher_instance.click_launcher_icon(calc_icon) - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_keynav_cancel_on_quicklist_activate(self): """A single click on a quicklist item must cancel keynav.""" self.start_keynav_with_cleanup_cancel() self.launcher_instance.key_nav_enter_quicklist() - bfb_icon = self.launcher.model.get_bfb_icon() + bfb_icon = self.unity.launcher.model.get_bfb_icon() bfb_ql = bfb_icon.get_quicklist() bfb_ql.click_item(bfb_ql.selected_item) - self.addCleanup(self.dash.ensure_hidden) + self.addCleanup(self.unity.dash.ensure_hidden) - self.assertThat(self.dash.visible, Eventually(Equals(True))) - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_keynav_changes_panel(self): """The panel title must change when in key nav mode.""" self.start_keynav_with_cleanup_cancel() - self.assertThat(self.panels.get_active_panel().title, Eventually(Equals("Search your computer and online sources"))) + self.assertThat(self.unity.panels.get_active_panel().title, Eventually(Equals("Search your computer and online sources"))) diff --git a/tests/autopilot/unity/tests/launcher/test_reveal.py b/tests/autopilot/unity/tests/launcher/test_reveal.py index 45976fa7b..d1bfb22b8 100644 --- a/tests/autopilot/unity/tests/launcher/test_reveal.py +++ b/tests/autopilot/unity/tests/launcher/test_reveal.py @@ -79,21 +79,21 @@ class LauncherRevealTests(LauncherTestCase): char_win2 = self.start_app_window("Character Map") char_app = char_win1.application - char_icon = self.launcher.model.get_icon(desktop_id=char_app.desktop_file) + char_icon = self.unity.launcher.model.get_icon(desktop_id=char_app.desktop_file) self.launcher_instance.click_launcher_icon(char_icon, move_mouse_after=False) - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) self.launcher_instance.click_launcher_icon(char_icon, move_mouse_after=False) self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True))) - self.assertThat(self.window_manager.scale_active, Eventually(Equals(False))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(False))) def test_launcher_stays_open_after_icon_click(self): """Clicking on a launcher icon must not hide the launcher.""" char_win = self.start_app_window("Character Map") char_app = char_win.application - char_icon = self.launcher.model.get_icon(desktop_id=char_app.desktop_file) + char_icon = self.unity.launcher.model.get_icon(desktop_id=char_app.desktop_file) self.launcher_instance.click_launcher_icon(char_icon, move_mouse_after=False) # Have to sleep to give the launcher time to hide (what the old behavior was) @@ -103,13 +103,13 @@ class LauncherRevealTests(LauncherTestCase): def test_new_icon_has_the_shortcut(self): """New icons should have an associated shortcut""" - if self.launcher.model.num_bamf_launcher_icons() >= 10: + if self.unity.launcher.model.num_bamf_launcher_icons() >= 10: self.skip("There are already more than 9 icons in the launcher") desktop_file = self.KNOWN_APPS['Calculator']['desktop-file'] - if self.launcher.model.get_icon(desktop_id=desktop_file) != None: + if self.unity.launcher.model.get_icon(desktop_id=desktop_file) != None: self.skip("Calculator icon is already on the launcher.") self.start_app('Calculator') - icon = self.launcher.model.get_icon(desktop_id=desktop_file) + icon = self.unity.launcher.model.get_icon(desktop_id=desktop_file) self.assertThat(icon.shortcut, GreaterThan(0)) diff --git a/tests/autopilot/unity/tests/launcher/test_shortcut.py b/tests/autopilot/unity/tests/launcher/test_shortcut.py index 9cb3093ff..28d661395 100644 --- a/tests/autopilot/unity/tests/launcher/test_shortcut.py +++ b/tests/autopilot/unity/tests/launcher/test_shortcut.py @@ -37,7 +37,7 @@ class LauncherShortcutTests(LauncherTestCase): self.launcher_instance.switcher_start() self.addCleanup(self.launcher_instance.switcher_cancel) - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(True))) self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(True))) def test_launcher_switcher_next_keeps_shortcuts(self): diff --git a/tests/autopilot/unity/tests/launcher/test_switcher.py b/tests/autopilot/unity/tests/launcher/test_switcher.py index 786826f12..ad3d3c590 100644 --- a/tests/autopilot/unity/tests/launcher/test_switcher.py +++ b/tests/autopilot/unity/tests/launcher/test_switcher.py @@ -36,14 +36,14 @@ class LauncherSwitcherTests(LauncherTestCase): def safe_quit_switcher(self): """Quit the keynav mode if it's engaged.""" - if self.launcher.key_nav_is_active: + if self.unity.launcher.key_nav_is_active: self.launcher_instance.switcher_cancel() def test_launcher_switcher_cancel(self): """Test that ending the launcher switcher actually works.""" self.launcher_instance.switcher_start() self.launcher_instance.switcher_cancel() - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) def test_launcher_switcher_cancel_resume_focus(self): """Test that ending the launcher switcher resume the focus.""" @@ -63,9 +63,9 @@ class LauncherSwitcherTests(LauncherTestCase): """Test that starting the Launcher switcher puts the keyboard focus on item 0.""" self.start_switcher_with_cleanup_cancel() - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True))) - self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(False))) - self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(True))) + self.assertThat(self.unity.launcher.key_nav_is_grabbed, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(Equals(0))) def test_launcher_switcher_next(self): """Moving to the next launcher item while switcher is activated must work.""" @@ -77,13 +77,13 @@ class LauncherSwitcherTests(LauncherTestCase): # make sure that the index has increased. This opens us to the # possibility that the launcher really is skipping forward more than one # icon at a time, but we can't do much about that. - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(0))) def test_launcher_switcher_prev(self): """Moving to the previous launcher item while switcher is activated must work.""" self.start_switcher_with_cleanup_cancel() self.launcher_instance.switcher_prev() - self.assertThat(self.launcher.key_nav_selection, Eventually(NotEquals(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(NotEquals(0))) def test_launcher_switcher_down(self): """Pressing the down arrow key while switcher is activated must work.""" @@ -95,13 +95,13 @@ class LauncherSwitcherTests(LauncherTestCase): # make sure that the index has increased. This opens us to the # possibility that the launcher really is skipping forward more than one # icon at a time, but we can't do much about that. - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(0))) def test_launcher_switcher_up(self): """Pressing the up arrow key while switcher is activated must work.""" self.start_switcher_with_cleanup_cancel() self.launcher_instance.switcher_up() - self.assertThat(self.launcher.key_nav_selection, Eventually(NotEquals(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(NotEquals(0))) def test_launcher_switcher_next_doesnt_show_shortcuts(self): """Moving forward in launcher switcher must not show launcher shortcuts.""" @@ -123,25 +123,25 @@ class LauncherSwitcherTests(LauncherTestCase): """Launcher Switcher must loop through icons when cycling forwards""" self.start_switcher_with_cleanup_cancel() prev_icon = 0 - num_icons = self.launcher.model.num_launcher_icons() + num_icons = self.unity.launcher.model.num_launcher_icons() logger.info("This launcher has %d icons", num_icons) for icon in range(1, num_icons): self.launcher_instance.switcher_next() # FIXME We can't directly check for selection/icon number equalty # since the launcher model also contains "hidden" icons that aren't # shown, so the selection index can increment by more than 1. - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon))) - prev_icon = self.launcher.key_nav_selection + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon))) + prev_icon = self.unity.launcher.key_nav_selection self.launcher_instance.switcher_next() - self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0))) + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(Equals(0))) def test_launcher_switcher_cycling_backward(self): """Launcher Switcher must loop through icons when cycling backwards""" self.start_switcher_with_cleanup_cancel() self.launcher_instance.switcher_prev() - # FIXME We can't directly check for self.launcher.num_launcher_icons - 1 - self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(1))) + # FIXME We can't directly check for self.unity.launcher.num_launcher_icons - 1 + self.assertThat(self.unity.launcher.key_nav_selection, Eventually(GreaterThan(1))) def test_launcher_switcher_activate_keep_focus(self): """Activating a running launcher icon should focus the application.""" @@ -165,4 +165,4 @@ class LauncherSwitcherTests(LauncherTestCase): sleep(.25) self.keyboard.press_and_release("Escape") sleep(.25) - self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False))) + self.assertThat(self.unity.launcher.key_nav_is_active, Eventually(Equals(False))) diff --git a/tests/autopilot/unity/tests/launcher/test_visual.py b/tests/autopilot/unity/tests/launcher/test_visual.py index 6b1fd7805..620e2e596 100644 --- a/tests/autopilot/unity/tests/launcher/test_visual.py +++ b/tests/autopilot/unity/tests/launcher/test_visual.py @@ -28,9 +28,9 @@ class LauncherVisualTests(LauncherTestCase): Tests fix for bug #913569. """ - bfb = self.launcher.model.get_bfb_icon() + bfb = self.unity.launcher.model.get_bfb_icon() self.mouse.move(bfb.center_x, bfb.center_y) - self.dash.ensure_visible() + self.unity.dash.ensure_visible() sleep(1) # We can't use 'launcher_instance.switcher_start()' since it moves the mouse. self.keybinding_hold_part_then_tap("launcher/switcher") @@ -38,15 +38,15 @@ class LauncherVisualTests(LauncherTestCase): self.addCleanup(self.keybinding, "launcher/switcher/exit") self.keybinding_tap("launcher/switcher/next") - for icon in self.launcher.model.get_launcher_icons(): + for icon in self.unity.launcher.model.get_launcher_icons(): self.assertThat(icon.desaturated, Eventually(Equals(False))) def test_opening_dash_desaturates_icons(self): """Opening the dash must desaturate all the launcher icons.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) - for icon in self.launcher.model.get_launcher_icons(): + for icon in self.unity.launcher.model.get_launcher_icons(): if isinstance(icon, BFBLauncherIcon): self.assertThat(icon.desaturated, Eventually(Equals(False))) else: @@ -58,19 +58,19 @@ class LauncherVisualTests(LauncherTestCase): x,y,w,h = launcher_instance.geometry self.mouse.move(x + w/2, y + h/2) sleep(.5) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) - for icon in self.launcher.model.get_launcher_icons(): + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) + for icon in self.unity.launcher.model.get_launcher_icons(): self.assertThat(icon.desaturated, Eventually(Equals(False))) def test_mouse_over_with_dash_open_desaturates_icons(self): """Moving mouse over launcher with dash open must saturate icons.""" launcher_instance = self.get_launcher() - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) sleep(.5) x,y,w,h = launcher_instance.geometry self.mouse.move(x + w/2, y + h/2) sleep(.5) - for icon in self.launcher.model.get_launcher_icons(): + for icon in self.unity.launcher.model.get_launcher_icons(): self.assertThat(icon.desaturated, Eventually(Equals(False))) diff --git a/tests/autopilot/unity/tests/test_command_lens.py b/tests/autopilot/unity/tests/test_command_lens.py index 13db7a2da..403e16062 100644 --- a/tests/autopilot/unity/tests/test_command_lens.py +++ b/tests/autopilot/unity/tests/test_command_lens.py @@ -24,38 +24,38 @@ class CommandLensSearchTests(UnityTestCase): gettext.install("unity-lens-applications") def tearDown(self): - self.dash.ensure_hidden() + self.unity.dash.ensure_hidden() super(CommandLensSearchTests, self).tearDown() def test_no_results(self): """An empty string should get no results.""" - self.dash.reveal_command_lens() - command_lens = self.dash.get_current_lens() + self.unity.dash.reveal_command_lens() + command_lens = self.unity.dash.get_current_lens() - if self.dash.search_string != "": + if self.unity.dash.search_string != "": self.keyboard.press_and_release("Delete") - self.assertThat(self.dash.search_string, Eventually(Equals(""))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(""))) results_category = command_lens.get_category_by_name(_("Results")) self.assertThat(results_category.is_visible, Eventually(Equals(False))) def test_results_category_appears(self): """Results category must appear when there are some results.""" - self.dash.reveal_command_lens() - command_lens = self.dash.get_current_lens() + self.unity.dash.reveal_command_lens() + command_lens = self.unity.dash.get_current_lens() # lots of apps start with 'a'... self.keyboard.type("a") - self.assertThat(self.dash.search_string, Eventually(Equals("a"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("a"))) results_category = command_lens.get_category_by_name(_("Results")) self.assertThat(results_category.is_visible, Eventually(Equals(True))) def test_result_category_actually_contains_results(self): """With a search string of 'a', the results category must contain some results.""" - self.dash.reveal_command_lens() - command_lens = self.dash.get_current_lens() + self.unity.dash.reveal_command_lens() + command_lens = self.unity.dash.get_current_lens() # lots of apps start with 'a'... self.keyboard.type("a") - self.assertThat(self.dash.search_string, Eventually(Equals("a"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("a"))) results_category = command_lens.get_category_by_name(_("Results")) results = results_category.get_results() self.assertTrue(results) @@ -66,7 +66,7 @@ class CommandLensSearchTests(UnityTestCase): self.close_all_app("Text Editor") sleep(1) - self.dash.reveal_command_lens() + self.unity.dash.reveal_command_lens() self.keyboard.type("g") sleep(1) self.keyboard.type("edit", 0.1) @@ -77,12 +77,12 @@ class CommandLensSearchTests(UnityTestCase): def test_ctrl_tab_switching(self): """Pressing Ctrl+Tab after launching command lens must switch to Home lens.""" - self.dash.reveal_command_lens() + self.unity.dash.reveal_command_lens() self.keybinding("dash/lens/next") - self.assertThat(self.dash.active_lens, Eventually(Equals("home.lens"))) + self.assertThat(self.unity.dash.active_lens, Eventually(Equals("home.lens"))) def test_ctrl_shift_tab_switching(self): """Pressing Ctrl+Shift+Tab after launching command lens must switch to Video lens.""" - self.dash.reveal_command_lens() + self.unity.dash.reveal_command_lens() self.keybinding("dash/lens/prev") - self.assertThat(self.dash.active_lens, Eventually(Equals("video.lens"))) + self.assertThat(self.unity.dash.active_lens, Eventually(Equals("video.lens"))) diff --git a/tests/autopilot/unity/tests/test_dash.py b/tests/autopilot/unity/tests/test_dash.py index 24923dec2..0109b0f3b 100644 --- a/tests/autopilot/unity/tests/test_dash.py +++ b/tests/autopilot/unity/tests/test_dash.py @@ -24,9 +24,9 @@ class DashTestCase(UnityTestCase): super(DashTestCase, self).setUp() self.set_unity_log_level("unity.shell.compiz", "DEBUG") self.set_unity_log_level("unity.launcher", "DEBUG") - self.dash.ensure_hidden() + self.unity.dash.ensure_hidden() # On shutdown, ensure hidden too. Also add a delay. Cleanup is LIFO. - self.addCleanup(self.dash.ensure_hidden) + self.addCleanup(self.unity.dash.ensure_hidden) self.addCleanup(sleep, 1) @@ -35,68 +35,68 @@ class DashRevealTests(DashTestCase): def test_dash_reveal(self): """Ensure we can show and hide the dash.""" - self.dash.ensure_visible() - self.dash.ensure_hidden() + self.unity.dash.ensure_visible() + self.unity.dash.ensure_hidden() def test_application_lens_shortcut(self): """Application lense must reveal when Super+a is pressed.""" - self.dash.reveal_application_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens'))) + self.unity.dash.reveal_application_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('applications.lens'))) def test_music_lens_shortcut(self): """Music lense must reveal when Super+w is pressed.""" - self.dash.reveal_music_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('music.lens'))) + self.unity.dash.reveal_music_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('music.lens'))) def test_file_lens_shortcut(self): """File lense must reveal when Super+f is pressed.""" - self.dash.reveal_file_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('files.lens'))) + self.unity.dash.reveal_file_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('files.lens'))) def test_video_lens_shortcut(self): """Video lens must reveal when super+v is pressed.""" - self.dash.reveal_video_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('video.lens'))) + self.unity.dash.reveal_video_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('video.lens'))) def test_command_lens_shortcut(self): """Run Command lens must reveat on alt+F2.""" - self.dash.reveal_command_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('commands.lens'))) + self.unity.dash.reveal_command_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('commands.lens'))) def test_can_go_from_dash_to_command_lens(self): """Switch to command lens without closing the dash.""" - self.dash.ensure_visible() - self.dash.reveal_command_lens() - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.unity.dash.ensure_visible() + self.unity.dash.reveal_command_lens() + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_alt_f4_close_dash(self): """Dash must close on alt+F4.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.press_and_release("Alt+F4") - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_alt_f4_close_dash_with_capslock_on(self): """Dash must close on Alt+F4 even when the capslock is turned on.""" self.keyboard.press_and_release("Caps_Lock") self.addCleanup(self.keyboard.press_and_release, "Caps_Lock") - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.press_and_release("Alt+F4") - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_closes_mouse_down_outside(self): """Test that a mouse down outside of the dash closes the dash.""" - self.dash.ensure_visible() - current_monitor = self.dash.monitor + self.unity.dash.ensure_visible() + current_monitor = self.unity.dash.monitor - (x,y,w,h) = self.dash.geometry + (x,y,w,h) = self.unity.dash.geometry (screen_x,screen_y,screen_w,screen_h) = self.screen_geo.get_monitor_geometry(current_monitor) self.mouse.move(x + w + (screen_w-((screen_x-x)+w))/2, y + h + (screen_h-((screen_y-y)+h))/2) self.mouse.click() - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_closes_then_focuses_window_on_mouse_down(self): """If 2 windows are open with 1 maximized and the non-maxmized @@ -107,7 +107,7 @@ class DashRevealTests(DashTestCase): self.keybinding("window/maximize") self.start_app("Calculator") - self.dash.ensure_visible() + self.unity.dash.ensure_visible() #Click bottom right of the screen w = self.screen_geo.get_screen_width() @@ -117,6 +117,7 @@ class DashRevealTests(DashTestCase): self.assertProperty(char_win, is_active=True) + class DashRevealWithSpreadTests(DashTestCase): """Test the interaction of the Dash with the Spead/Scale @@ -134,49 +135,49 @@ class DashRevealWithSpreadTests(DashTestCase): def test_dash_closes_on_spread(self): """This test shows that when the spread is initiated, the dash closes.""" self.start_placeholder_app() - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.addCleanup(self.keybinding, "spread/cancel") self.keybinding("spread/start") - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_dash_opens_when_in_spread(self): """This test shows the dash opens when in spread mode.""" self.start_placeholder_app() self.keybinding("spread/start") - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) - self.dash.ensure_visible() - self.assertThat(self.dash.visible, Eventually(Equals(True))) + self.unity.dash.ensure_visible() + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) def test_command_lens_opens_when_in_spread(self): """This test shows the command lens opens when in spread mode.""" self.start_placeholder_app() self.keybinding("spread/start") - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) - self.dash.reveal_command_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('commands.lens'))) + self.unity.dash.reveal_command_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('commands.lens'))) def test_lens_opens_when_in_spread(self): """This test shows that any lens opens when in spread mode.""" self.start_placeholder_app() self.keybinding("spread/start") - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) - self.dash.reveal_application_lens() - self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens'))) + self.unity.dash.reveal_application_lens() + self.assertThat(self.unity.dash.active_lens, Eventually(Equals('applications.lens'))) class DashSearchInputTests(DashTestCase): """Test features involving input to the dash search""" def assertSearchText(self, text): - self.assertThat(self.dash.search_string, Eventually(Equals(text))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(text))) def test_search_keyboard_focus(self): """Dash must put keyboard focus on the search bar at all times.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.type("Hello") self.assertSearchText("Hello") @@ -192,28 +193,28 @@ class DashMultiKeyTests(DashSearchInputTests): def test_multi_key(self): """Pressing 'Multi_key' must not add any characters to the search.""" - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() self.keyboard.press_and_release('Multi_key') self.keyboard.type("o") self.assertSearchText("") def test_multi_key_o(self): """Pressing the sequences 'Multi_key' + '^' + 'o' must produce 'ô'.""" - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() self.keyboard.press_and_release('Multi_key') self.keyboard.type("^o") self.assertSearchText(u'\xf4') def test_multi_key_copyright(self): """Pressing the sequences 'Multi_key' + 'c' + 'o' must produce '©'.""" - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() self.keyboard.press_and_release('Multi_key') self.keyboard.type("oc") self.assertSearchText(u'\xa9') def test_multi_key_delete(self): """Pressing 'Multi_key' must not get stuck looking for a sequence.""" - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() self.keyboard.type("dd") self.keyboard.press_and_release('Multi_key') self.keyboard.press_and_release('BackSpace') @@ -226,21 +227,21 @@ class DashKeyNavTests(DashTestCase): def test_lensbar_gets_keyfocus(self): """Test that the lensbar gets key focus after using Down keypresses.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() # Make sure that the lens bar can get the focus - for i in range(self.dash.get_num_rows()): + for i in range(self.unity.dash.get_num_rows()): self.keyboard.press_and_release("Down") - lensbar = self.dash.view.get_lensbar() + lensbar = self.unity.dash.view.get_lensbar() self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals(''))) def test_lensbar_focus_changes(self): """Lensbar focused icon should change with Left and Right keypresses.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() - for i in range(self.dash.get_num_rows()): + for i in range(self.unity.dash.get_num_rows()): self.keyboard.press_and_release("Down") - lensbar = self.dash.view.get_lensbar() + lensbar = self.unity.dash.view.get_lensbar() current_focused_icon = lensbar.focused_lens_icon @@ -252,12 +253,12 @@ class DashKeyNavTests(DashTestCase): def test_lensbar_enter_activation(self): """Must be able to activate LensBar icons that have focus with an Enter keypress.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() - for i in range(self.dash.get_num_rows()): + for i in range(self.unity.dash.get_num_rows()): self.keyboard.press_and_release("Down") self.keyboard.press_and_release("Right") - lensbar = self.dash.view.get_lensbar() + lensbar = self.unity.dash.view.get_lensbar() focused_icon = lensbar.focused_lens_icon self.keyboard.press_and_release("Enter") @@ -269,12 +270,12 @@ class DashKeyNavTests(DashTestCase): def test_focus_returns_to_searchbar(self): """This test makes sure that the focus is returned to the searchbar of the newly activated lens.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() - for i in range(self.dash.get_num_rows()): + for i in range(self.unity.dash.get_num_rows()): self.keyboard.press_and_release("Down") self.keyboard.press_and_release("Right") - lensbar = self.dash.view.get_lensbar() + lensbar = self.unity.dash.view.get_lensbar() focused_icon = lensbar.focused_lens_icon self.keyboard.press_and_release("Enter") @@ -284,7 +285,7 @@ class DashKeyNavTests(DashTestCase): # Now we make sure if the newly activated lens searchbar have the focus. self.keyboard.type("HasFocus") - self.assertThat(self.dash.search_string, Eventually(Equals("HasFocus"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("HasFocus"))) def test_category_header_keynav(self): """ Tests that a category header gets focus when 'down' is pressed after the @@ -294,10 +295,10 @@ class DashKeyNavTests(DashTestCase): focused, not the first and from doing this it seems that it's common for a header other than the first to get focus. """ - self.dash.ensure_visible() + self.unity.dash.ensure_visible() # Make sure that a category have the focus. self.keyboard.press_and_release("Down") - lens = self.dash.get_current_lens() + lens = self.unity.dash.get_current_lens() category = lens.get_focused_category() self.assertIsNot(category, None) # Make sure that the category is highlighted. @@ -305,13 +306,13 @@ class DashKeyNavTests(DashTestCase): def test_control_tab_lens_cycle(self): """This test makes sure that Ctrl+Tab cycles lenses.""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.press('Control') self.keyboard.press_and_release('Tab') self.keyboard.release('Control') - lensbar = self.dash.view.get_lensbar() + lensbar = self.unity.dash.view.get_lensbar() self.assertEqual(lensbar.active_lens, u'applications.lens') self.keyboard.press('Control') @@ -324,8 +325,8 @@ class DashKeyNavTests(DashTestCase): def test_tab_cycle_category_headers(self): """ Makes sure that pressing tab cycles through the category headers""" - self.dash.ensure_visible() - lens = self.dash.get_current_lens() + self.unity.dash.ensure_visible() + lens = self.unity.dash.get_current_lens() # Test that tab cycles through the categories. # + 1 is to cycle back to first header @@ -336,20 +337,20 @@ class DashKeyNavTests(DashTestCase): def test_tab_with_filter_bar(self): """ This test makes sure that Tab works well with the filter bara.""" - self.dash.reveal_application_lens() - lens = self.dash.get_current_lens() + self.unity.dash.reveal_application_lens() + lens = self.unity.dash.get_current_lens() # Tabs to last category for i in range(lens.get_num_visible_categories()): self.keyboard.press_and_release('Tab') self.keyboard.press_and_release('Tab') - self.assertThat(self.dash.searchbar.expander_has_focus, Eventually(Equals(True))) + self.assertThat(self.unity.dash.searchbar.expander_has_focus, Eventually(Equals(True))) filter_bar = lens.get_filterbar() - if not self.dash.searchbar.showing_filters: + if not self.unity.dash.searchbar.showing_filters: self.keyboard.press_and_release('Enter') - self.assertThat(self.dash.searchbar.showing_filters, Eventually(Equals(True))) + self.assertThat(self.unity.dash.searchbar.showing_filters, Eventually(Equals(True))) self.addCleanup(filter_bar.ensure_collapsed) for i in range(filter_bar.get_num_filters()): @@ -366,8 +367,8 @@ class DashKeyNavTests(DashTestCase): """This test makes sure that bottom-up key navigation works well in the dash filter bar. """ - self.dash.reveal_application_lens() - lens = self.dash.get_current_lens() + self.unity.dash.reveal_application_lens() + lens = self.unity.dash.get_current_lens() filter_bar = lens.get_filterbar() # Need to ensure the filter expander has focus, so if it's already @@ -399,21 +400,21 @@ class DashClipboardTests(DashTestCase): def test_ctrl_a(self): """ This test if ctrl+a selects all text """ - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.type("SelectAll") - self.assertThat(self.dash.search_string, Eventually(Equals("SelectAll"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("SelectAll"))) self.keyboard.press_and_release("Ctrl+a") self.keyboard.press_and_release("Delete") - self.assertThat(self.dash.search_string, Eventually(Equals(''))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(''))) def test_ctrl_c(self): """ This test if ctrl+c copies text into the clipboard """ - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.type("Copy") - self.assertThat(self.dash.search_string, Eventually(Equals("Copy"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("Copy"))) self.keyboard.press_and_release("Ctrl+a") self.keyboard.press_and_release("Ctrl+c") @@ -422,44 +423,44 @@ class DashClipboardTests(DashTestCase): def test_ctrl_x(self): """ This test if ctrl+x deletes all text and copys it """ - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.type("Cut") - self.assertThat(self.dash.search_string, Eventually(Equals("Cut"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("Cut"))) self.keyboard.press_and_release("Ctrl+a") self.keyboard.press_and_release("Ctrl+x") - self.assertThat(self.dash.search_string, Eventually(Equals(""))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(""))) self.assertThat(get_clipboard_contents, Eventually(Equals('Cut'))) def test_ctrl_c_v(self): """ This test if ctrl+c and ctrl+v copies and pastes text""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.type("CopyPaste") - self.assertThat(self.dash.search_string, Eventually(Equals("CopyPaste"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("CopyPaste"))) self.keyboard.press_and_release("Ctrl+a") self.keyboard.press_and_release("Ctrl+c") self.keyboard.press_and_release("Ctrl+v") self.keyboard.press_and_release("Ctrl+v") - self.assertThat(self.dash.search_string, Eventually(Equals('CopyPasteCopyPaste'))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals('CopyPasteCopyPaste'))) def test_ctrl_x_v(self): """ This test if ctrl+x and ctrl+v cuts and pastes text""" - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.keyboard.type("CutPaste") - self.assertThat(self.dash.search_string, Eventually(Equals("CutPaste"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("CutPaste"))) self.keyboard.press_and_release("Ctrl+a") self.keyboard.press_and_release("Ctrl+x") self.keyboard.press_and_release("Ctrl+v") self.keyboard.press_and_release("Ctrl+v") - self.assertThat(self.dash.search_string, Eventually(Equals('CutPasteCutPaste'))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals('CutPasteCutPaste'))) def test_middle_click_paste(self): """Tests if Middle mouse button pastes into searchbar""" @@ -469,28 +470,28 @@ class DashClipboardTests(DashTestCase): self.keyboard.type("ThirdButtonPaste") self.keyboard.press_and_release("Ctrl+a") - self.dash.ensure_visible() + self.unity.dash.ensure_visible() - self.mouse.move(self.dash.searchbar.x + self.dash.searchbar.width / 2, - self.dash.searchbar.y + self.dash.searchbar.height / 2) + self.mouse.move(self.unity.dash.searchbar.x + self.unity.dash.searchbar.width / 2, + self.unity.dash.searchbar.y + self.unity.dash.searchbar.height / 2) self.mouse.click(button=2) - self.assertThat(self.dash.search_string, Eventually(Equals('ThirdButtonPaste'))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals('ThirdButtonPaste'))) class DashKeyboardFocusTests(DashTestCase): """Tests that keyboard focus works.""" def assertSearchText(self, text): - self.assertThat(self.dash.search_string, Eventually(Equals(text))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(text))) def test_filterbar_expansion_leaves_kb_focus(self): """Expanding or collapsing the filterbar must keave keyboard focus in the search bar. """ - self.dash.reveal_application_lens() - filter_bar = self.dash.get_current_lens().get_filterbar() + self.unity.dash.reveal_application_lens() + filter_bar = self.unity.dash.get_current_lens().get_filterbar() filter_bar.ensure_collapsed() self.keyboard.type("hello") @@ -502,8 +503,8 @@ class DashKeyboardFocusTests(DashTestCase): def test_keep_focus_on_application_opens(self): """The Dash must keep key focus as well as stay open if an app gets opened from an external source. """ - self.dash.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.start_app_window("Calculator") sleep(1) @@ -517,33 +518,33 @@ class DashLensResultsTests(DashTestCase): def test_results_message_empty_search(self): """This tests a message is not shown when there is no text.""" - self.dash.reveal_application_lens() - lens = self.dash.get_current_lens() + self.unity.dash.reveal_application_lens() + lens = self.unity.dash.get_current_lens() self.assertThat(lens.no_results_active, Eventually(Equals(False))) def test_results_message(self): """This test no mesage will be shown when results are there.""" - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() self.keyboard.type("Terminal") - self.assertThat(self.dash.search_string, Eventually(Equals("Terminal"))) - lens = self.dash.get_current_lens() + self.assertThat(self.unity.dash.search_string, Eventually(Equals("Terminal"))) + lens = self.unity.dash.get_current_lens() self.assertThat(lens.no_results_active, Eventually(Equals(False))) def test_no_results_message(self): """This test shows a message will appear in the lens.""" - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() self.keyboard.type("qwerlkjzvxc") - self.assertThat(self.dash.search_string, Eventually(Equals("qwerlkjzvxc"))) - lens = self.dash.get_current_lens() + self.assertThat(self.unity.dash.search_string, Eventually(Equals("qwerlkjzvxc"))) + lens = self.unity.dash.get_current_lens() self.assertThat(lens.no_results_active, Eventually(Equals(True))) def test_results_update_on_filter_changed(self): """This test makes sure the results change when filters change.""" gettext.install("unity-lens-applications") - self.dash.reveal_application_lens() - lens = self.dash.get_current_lens() + self.unity.dash.reveal_application_lens() + lens = self.unity.dash.get_current_lens() self.keyboard.type(" ") - self.assertThat(self.dash.search_string, Eventually(Equals(" "))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(" "))) results_category = lens.get_category_by_name(_("Installed")) old_results = results_category.get_results() @@ -556,12 +557,12 @@ class DashLensResultsTests(DashTestCase): self.keyboard.press_and_release('Tab') self.keyboard.press_and_release('Tab') - self.assertThat(self.dash.searchbar.expander_has_focus, Eventually(Equals(True))) + self.assertThat(self.unity.dash.searchbar.expander_has_focus, Eventually(Equals(True))) filter_bar = lens.get_filterbar() - if not self.dash.searchbar.showing_filters: + if not self.unity.dash.searchbar.showing_filters: self.keyboard.press_and_release('Enter') - self.assertThat(self.dash.searchbar.showing_filters, Eventually(Equals(True))) + self.assertThat(self.unity.dash.searchbar.showing_filters, Eventually(Equals(True))) if add_cleanup: self.addCleanup(filter_bar.ensure_collapsed) @@ -593,9 +594,9 @@ class DashVisualTests(DashTestCase): def test_closing_dash_hides_current_lens(self): """When exiting from the dash the current lens must set it self to not visible.""" - self.dash.ensure_visible() - lens = self.dash.get_current_lens() - self.dash.ensure_hidden() + self.unity.dash.ensure_visible() + lens = self.unity.dash.get_current_lens() + self.unity.dash.ensure_hidden() self.assertThat(lens.visible, Eventually(Equals(False))) @@ -604,20 +605,20 @@ class DashVisualTests(DashTestCase): has a non-default width. """ self.set_unity_option('icon_size', 60) - self.dash.ensure_visible() + self.unity.dash.ensure_visible() - monitor = self.dash.monitor - launcher = self.launcher.get_launcher_for_monitor(monitor) + monitor = self.unity.dash.monitor + launcher = self.unity.launcher.get_launcher_for_monitor(monitor) - self.assertThat(self.dash.geometry[0], Eventually(Equals(launcher.geometry[0] + launcher.geometry[2] - 1))) + self.assertThat(self.unity.dash.geometry[0], Eventually(Equals(launcher.geometry[0] + launcher.geometry[2] - 1))) def test_see_more_result_alignment(self): """The see more results label should be baseline aligned with the category name label. """ - self.dash.reveal_application_lens() + self.unity.dash.reveal_application_lens() - lens = self.dash.get_current_lens() + lens = self.unity.dash.get_current_lens() groups = lens.get_groups() for group in groups: @@ -632,8 +633,8 @@ class DashLensBarTests(DashTestCase): def setUp(self): super(DashLensBarTests, self).setUp() - self.dash.ensure_visible() - self.lensbar = self.dash.view.get_lensbar() + self.unity.dash.ensure_visible() + self.lensbar = self.unity.dash.view.get_lensbar() def test_click_inside_highlight(self): """Lens selection should work when clicking in @@ -653,37 +654,37 @@ class DashBorderTests(DashTestCase): """ def setUp(self): super(DashBorderTests, self).setUp() - self.dash.ensure_visible() + self.unity.dash.ensure_visible() def test_click_right_border(self): """Clicking on the right dash border should do nothing, *NOT* close the dash. """ - if (self.dash.view.form_factor != "desktop"): + if (self.unity.dash.view.form_factor != "desktop"): self.skip("Not in desktop form-factor.") - x = self.dash.view.x + self.dash.view.width + self.dash.view.right_border_width / 2 - y = self.dash.view.y + self.dash.view.height / 2 + x = self.unity.dash.view.x + self.unity.dash.view.width + self.unity.dash.view.right_border_width / 2 + y = self.unity.dash.view.y + self.unity.dash.view.height / 2 self.mouse.move(x, y) self.mouse.click() - self.assertThat(self.dash.visible, Eventually(Equals(True))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) def test_click_bottom_border(self): """Clicking on the bottom dash border should do nothing, *NOT* close the dash. """ - if (self.dash.view.form_factor != "desktop"): + if (self.unity.dash.view.form_factor != "desktop"): self.skip("Not in desktop form-factor.") - x = self.dash.view.x + self.dash.view.width / 2 - y = self.dash.view.y + self.dash.view.height + self.dash.view.bottom_border_height / 2 + x = self.unity.dash.view.x + self.unity.dash.view.width / 2 + y = self.unity.dash.view.y + self.unity.dash.view.height + self.unity.dash.view.bottom_border_height / 2 self.mouse.move(x, y) self.mouse.click() - self.assertThat(self.dash.visible, Eventually(Equals(True))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) class CategoryHeaderTests(DashTestCase): @@ -694,13 +695,13 @@ class CategoryHeaderTests(DashTestCase): the view. """ gettext.install("unity-lens-applications", unicode=True) - lens = self.dash.reveal_application_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_application_lens() + self.addCleanup(self.unity.dash.ensure_hidden) category = lens.get_category_by_name(_("Installed")) is_expanded = category.is_expanded - self.mouse.move(self.dash.view.x + self.dash.view.width / 2, + self.mouse.move(self.unity.dash.view.x + self.unity.dash.view.width / 2, category.header_y + category.header_height / 2) self.mouse.click() @@ -720,19 +721,19 @@ class PreviewInvocationTests(DashTestCase): """ gettext.install("unity-lens-applications", unicode=True) - lens = self.dash.reveal_application_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_application_lens() + self.addCleanup(self.unity.dash.ensure_hidden) category = lens.get_category_by_name(_("More suggestions")) results = category.get_results() result = results[0] # result.preview handles finding xy co-ords and right mouse-click result.preview() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_files_lens_preview_open_close(self): """Right-clicking on a files lens result must show its @@ -748,8 +749,8 @@ class PreviewInvocationTests(DashTestCase): self.addCleanup(self.close_all_app, 'Text Editor') self.assertProperty(gedit_win, is_focused=True) - lens = self.dash.reveal_file_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_file_lens() + self.addCleanup(self.unity.dash.ensure_hidden) category = lens.get_category_by_name(_("Recent")) refresh_results_fn = lambda: len(category.get_results()) @@ -758,18 +759,18 @@ class PreviewInvocationTests(DashTestCase): result = results[0] # result.preview handles finding xy co-ords and right mouse-click result.preview() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_music_lens_preview_open_close(self): """Right-clicking on a music lens result must show its preview. """ - lens = self.dash.reveal_music_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_music_lens() + self.addCleanup(self.unity.dash.ensure_hidden) category = lens.get_category_by_name("Songs") # Incase there was no music ever played we skip the test instead @@ -782,11 +783,11 @@ class PreviewInvocationTests(DashTestCase): result = results[0] # result.preview handles finding xy co-ords and right mouse-click result.preview() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_video_lens_preview_open_close(self): """Right-clicking on a video lens result must show its @@ -805,8 +806,8 @@ class PreviewInvocationTests(DashTestCase): self.skipTest("This lens is probably empty") return category - lens = self.dash.reveal_video_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_video_lens() + self.addCleanup(self.unity.dash.ensure_hidden) self.assertThat(lambda: get_category(lens), Eventually(NotEquals(None))) category = get_category(lens) @@ -816,26 +817,26 @@ class PreviewInvocationTests(DashTestCase): result = results[0] # result.preview handles finding xy co-ords and right mouse-click result.preview() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_preview_key(self): """Pressing menu key on a selected dash result must show its preview. """ gettext.install("unity-lens-applications", unicode=True) - lens = self.dash.reveal_application_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_application_lens() + self.addCleanup(self.unity.dash.ensure_hidden) category = lens.get_category_by_name(_("More suggestions")) results = category.get_results() result = results[0] # result.preview_key() handles finding xy co-ords and key press result.preview_key() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) class PreviewNavigateTests(DashTestCase): @@ -845,8 +846,8 @@ class PreviewNavigateTests(DashTestCase): super(PreviewNavigateTests, self).setUp() gettext.install("unity-lens-applications", unicode=True) - lens = self.dash.reveal_application_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_application_lens() + self.addCleanup(self.unity.dash.ensure_hidden) results_category = lens.get_category_by_name(_("More suggestions")) # wait for results (we need 4 results to perorm the multi-navigation tests) @@ -856,9 +857,10 @@ class PreviewNavigateTests(DashTestCase): result = results[2] # 2 so we can navigate left result.preview() - self.assertThat(self.dash.view.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.view.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.view.get_preview_container, Eventually(NotEquals(None))) - self.preview_container = self.dash.view.get_preview_container() + self.preview_container = self.unity.dash.view.get_preview_container() def test_navigate_left(self): """Tests that left navigation works with previews.""" @@ -882,7 +884,7 @@ class PreviewNavigateTests(DashTestCase): # Test close preview after navigate self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_navigate_left_multi(self): """Tests that multiple left navigation works with previews.""" @@ -927,7 +929,7 @@ class PreviewNavigateTests(DashTestCase): # Test close preview after navigate self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_navigate_right_multi(self): """Tests that multiple right navigation works with previews.""" @@ -959,7 +961,7 @@ class PreviewNavigateTests(DashTestCase): self.keyboard.press_and_release("Escape") - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) class PreviewClickCancelTests(DashTestCase): @@ -967,8 +969,8 @@ class PreviewClickCancelTests(DashTestCase): def setUp(self): super(PreviewClickCancelTests, self).setUp() - lens = self.dash.reveal_application_lens() - self.addCleanup(self.dash.ensure_hidden) + lens = self.unity.dash.reveal_application_lens() + self.addCleanup(self.unity.dash.ensure_hidden) # Only testing an application preview for this test. self.keyboard.type("Software Updater") results_category = lens.get_category_by_name(_("Installed")) @@ -976,9 +978,9 @@ class PreviewClickCancelTests(DashTestCase): result = results[0] result.preview() - self.assertThat(self.dash.view.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.view.preview_displaying, Eventually(Equals(True))) - self.preview_container = self.dash.view.get_preview_container() + self.preview_container = self.unity.dash.view.get_preview_container() def test_left_click_on_preview_icon_cancel_preview(self): """Left click on preview icon must close preview.""" @@ -989,7 +991,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=1) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_middle_click_on_preview_icon_cancel_preview(self): """Middle click on preview icon must close preview.""" @@ -1000,7 +1002,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=2) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_right_click_on_preview_icon_cancel_preview(self): """Right click on preview icon must close preview.""" @@ -1011,7 +1013,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=3) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_left_click_on_preview_image_cancel_preview(self): """Left click on preview image must cancel the preview.""" @@ -1022,7 +1024,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=1) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_middle_click_on_preview_image_cancel_preview(self): """Middle click on preview image must cancel the preview.""" @@ -1033,7 +1035,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=2) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_right_click_on_preview_image_cancel_preview(self): """Right click on preview image must cancel the preview.""" @@ -1044,7 +1046,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=3) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_left_click_on_preview_text_cancel_preview(self): """Left click on some preview text must cancel the preview.""" @@ -1055,7 +1057,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=1) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_middle_click_on_preview_text_cancel_preview(self): """Middle click on some preview text must cancel the preview.""" @@ -1066,7 +1068,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=2) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_right_click_on_preview_text_cancel_preview(self): """Right click on some preview text must cancel the preview.""" @@ -1077,7 +1079,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=3) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_left_click_on_preview_ratings_widget_cancel_preview(self): """Left click on the ratings widget must cancel the preview.""" @@ -1088,7 +1090,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=1) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_middle_click_on_preview_ratings_widget_cancel_preview(self): """Middle click on the ratings widget must cancel the preview.""" @@ -1099,7 +1101,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=2) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_right_click_on_preview_ratings_widget_cancel_preview(self): """Right click on the ratings widget must cancel the preview.""" @@ -1110,7 +1112,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=3) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_left_click_on_preview_info_hint_cancel_preview(self): """Left click on the info hint must cancel the preview.""" @@ -1121,7 +1123,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=1) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_middle_click_on_preview_info_hint_cancel_preview(self): """Middle click on the info hint must cancel the preview.""" @@ -1132,7 +1134,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=2) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) def test_right_click_on_preview_info_hint_cancel_preview(self): """Right click on the info hint must cancel the preview.""" @@ -1143,7 +1145,7 @@ class PreviewClickCancelTests(DashTestCase): self.mouse.move(tx, ty) self.mouse.click(button=3) - self.assertThat(self.dash.preview_displaying, Eventually(Equals(False))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) class DashDBusIfaceTests(DashTestCase): @@ -1151,10 +1153,10 @@ class DashDBusIfaceTests(DashTestCase): def test_dash_hide(self): """Ensure we can hide the dash via HideDash() dbus method.""" - self.dash.ensure_visible() - self.dash.controller.hide_dash_via_dbus() - self.assertThat(self.dash.visible, Eventually(Equals(False))) - self.dash.ensure_hidden() + self.unity.dash.ensure_visible() + self.unity.dash.hide_dash_via_dbus() + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) + self.unity.dash.ensure_hidden() class DashCrossMonitorsTests(DashTestCase): @@ -1169,27 +1171,27 @@ class DashCrossMonitorsTests(DashTestCase): """If the dash is opened, then the mouse is moved to another monitor and the keyboard is used. The Dash must not move to that monitor. """ - current_monitor = self.dash.ideal_monitor + current_monitor = self.unity.dash.ideal_monitor - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.screen_geo.move_mouse_to_monitor((current_monitor + 1) % self.screen_geo.get_num_monitors()) self.keyboard.type("abc") - self.assertThat(self.dash.ideal_monitor, Eventually(Equals(current_monitor))) + self.assertThat(self.unity.dash.ideal_monitor, Eventually(Equals(current_monitor))) def test_dash_close_on_cross_monitor_click(self): """Dash must close when clicking on a window in a different screen.""" - self.addCleanup(self.dash.ensure_hidden) + self.addCleanup(self.unity.dash.ensure_hidden) for monitor in range(self.screen_geo.get_num_monitors()-1): self.screen_geo.move_mouse_to_monitor(monitor) - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.screen_geo.move_mouse_to_monitor(monitor+1) sleep(.5) self.mouse.click() - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) diff --git a/tests/autopilot/unity/tests/test_home_lens.py b/tests/autopilot/unity/tests/test_home_lens.py index 65de6875c..38539a3d6 100644 --- a/tests/autopilot/unity/tests/test_home_lens.py +++ b/tests/autopilot/unity/tests/test_home_lens.py @@ -22,22 +22,22 @@ class HomeLensSearchTests(UnityTestCase): super(HomeLensSearchTests, self).setUp() def tearDown(self): - self.dash.ensure_hidden() + self.unity.dash.ensure_hidden() super(HomeLensSearchTests, self).tearDown() def test_quick_run_app(self): """Hitting enter runs an application even though a search might not have fully finished yet. - + """ if self.app_is_running("Text Editor"): self.close_all_app("Text Editor") sleep(1) kb = self.keyboard - self.dash.ensure_visible() + self.unity.dash.ensure_visible() kb.type("g") - self.assertThat(self.dash.search_string, Eventually(Equals("g"))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals("g"))) kb.type("edit", 0.1) kb.press_and_release("Enter", 0.1) self.addCleanup(self.close_all_app, "Text Editor") diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index 0e85e7f6f..97938b9d9 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -47,12 +47,12 @@ class HudTestsBase(UnityTestCase): super(HudTestsBase, self).setUp() def tearDown(self): - self.hud.ensure_hidden() + self.unity.hud.ensure_hidden() super(HudTestsBase, self).tearDown() def get_num_active_launcher_icons(self): num_active = 0 - for icon in self.launcher.model.get_launcher_icons(): + for icon in self.unity.launcher.model.get_launcher_icons(): if icon.active and icon.visible: num_active += 1 return num_active @@ -77,56 +77,56 @@ class HudBehaviorTests(HudTestsBase): self.screen_geo.move_mouse_to_monitor(self.hud_monitor) def test_no_initial_values(self): - self.hud.ensure_visible() - self.assertThat(self.hud.num_buttons, Equals(0)) - self.assertThat(self.hud.selected_button, Equals(0)) + self.unity.hud.ensure_visible() + self.assertThat(self.unity.hud.num_buttons, Equals(0)) + self.assertThat(self.unity.hud.selected_button, Equals(0)) def test_check_a_values(self): - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type('a') - self.assertThat(self.hud.search_string, Eventually(Equals('a'))) - self.assertThat(self.hud.num_buttons, Eventually(Equals(5))) - self.assertThat(self.hud.selected_button, Eventually(Equals(1))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals('a'))) + self.assertThat(self.unity.hud.num_buttons, Eventually(Equals(5))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(1))) def test_up_down_arrows(self): - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type('a') - self.assertThat(self.hud.search_string, Eventually(Equals('a'))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals('a'))) self.keyboard.press_and_release('Down') - self.assertThat(self.hud.selected_button, Eventually(Equals(2))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(2))) self.keyboard.press_and_release('Down') - self.assertThat(self.hud.selected_button, Eventually(Equals(3))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(3))) self.keyboard.press_and_release('Down') - self.assertThat(self.hud.selected_button, Eventually(Equals(4))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(4))) self.keyboard.press_and_release('Down') - self.assertThat(self.hud.selected_button, Eventually(Equals(5))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(5))) # Down again stays on 5. self.keyboard.press_and_release('Down') - self.assertThat(self.hud.selected_button, Eventually(Equals(5))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(5))) self.keyboard.press_and_release('Up') - self.assertThat(self.hud.selected_button, Eventually(Equals(4))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(4))) self.keyboard.press_and_release('Up') - self.assertThat(self.hud.selected_button, Eventually(Equals(3))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(3))) self.keyboard.press_and_release('Up') - self.assertThat(self.hud.selected_button, Eventually(Equals(2))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(2))) self.keyboard.press_and_release('Up') - self.assertThat(self.hud.selected_button, Eventually(Equals(1))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(1))) # Up again stays on 1. self.keyboard.press_and_release('Up') - self.assertThat(self.hud.selected_button, Eventually(Equals(1))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(1))) def test_no_reset_selected_button(self): """Hud must not change selected button when results update over time.""" # TODO - this test doesn't test anything. Onmy system the results never update. # ideally we'd send artificial results to the hud from the test. - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type('is') - self.assertThat(self.hud.search_string, Eventually(Equals('is'))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals('is'))) self.keyboard.press_and_release('Down') - self.assertThat(self.hud.selected_button, Eventually(Equals(2))) + self.assertThat(self.unity.hud.selected_button, Eventually(Equals(2))) # long sleep to let the service send updated results sleep(10) - self.assertThat(self.hud.selected_button, Equals(2)) + self.assertThat(self.unity.hud.selected_button, Equals(2)) def test_slow_tap_not_reveal_hud(self): """A slow tap must not reveal the HUD.""" @@ -134,7 +134,7 @@ class HudBehaviorTests(HudTestsBase): # need a long sleep to ensure that we test after the hud controller has # seen the keypress. sleep(5) - self.assertThat(self.hud.visible, Equals(False)) + self.assertThat(self.unity.hud.visible, Equals(False)) def test_alt_f4_doesnt_show_hud(self): self.start_app('Calculator') @@ -142,7 +142,7 @@ class HudBehaviorTests(HudTestsBase): # Do a very fast Alt+F4 self.keyboard.press_and_release("Alt+F4", 0.05) sleep(1) - self.assertFalse(self.hud.visible) + self.assertFalse(self.unity.hud.visible) def test_reveal_hud_with_no_apps(self): """Hud must show even with no visible applications. @@ -151,11 +151,11 @@ class HudBehaviorTests(HudTestsBase): """ self.start_placeholder_app() - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) - self.hud.ensure_visible() - self.hud.ensure_hidden() + self.unity.hud.ensure_visible() + self.unity.hud.ensure_hidden() def test_restore_focus(self): """Ensures that once the hud is dismissed, the same application @@ -166,14 +166,14 @@ class HudBehaviorTests(HudTestsBase): # first ensure that the application has started and is focused self.assertEqual(calc.is_active, True) - self.hud.ensure_visible() - self.hud.ensure_hidden() + self.unity.hud.ensure_visible() + self.unity.hud.ensure_hidden() # again ensure that the application we started is focused self.assertEqual(calc.is_active, True) - self.hud.ensure_visible() - self.hud.ensure_hidden() + self.unity.hud.ensure_visible() + self.unity.hud.ensure_hidden() # why do we do this: ??? self.keyboard.press_and_release('Return') sleep(1) @@ -193,14 +193,14 @@ class HudBehaviorTests(HudTestsBase): self.keyboard.type(" ") self.keyboard.type("1") - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("undo") - hud_query_check = lambda: self.hud.selected_hud_button.label_no_formatting + hud_query_check = lambda: self.unity.hud.selected_hud_button.label_no_formatting self.assertThat(hud_query_check, Eventually(Equals("Edit > Undo"))) self.keyboard.press_and_release('Return') - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) self.assertProperty(gedit_win, is_focused=True) self.keyboard.press_and_release("Ctrl+s") @@ -211,18 +211,18 @@ class HudBehaviorTests(HudTestsBase): def test_hud_to_dash_has_key_focus(self): """When switching from the hud to the dash you don't lose key focus.""" - self.hud.ensure_visible() - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.hud.ensure_visible() + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.keyboard.type('focus1') - self.assertThat(self.dash.search_string, Eventually(Equals('focus1'))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals('focus1'))) def test_dash_to_hud_has_key_focus(self): """When switching from the dash to the hud you don't lose key focus.""" - self.dash.ensure_visible() - self.hud.ensure_visible() + self.unity.dash.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type('focus2') - self.assertThat(self.hud.search_string, Eventually(Equals('focus2'))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals('focus2'))) def test_hud_closes_on_workspace_switch(self): """This test shows that when you switch to another workspace the hud closes.""" @@ -230,19 +230,19 @@ class HudBehaviorTests(HudTestsBase): self.skipTest("This test requires enabled more than one workspace.") initial_workspace = self.workspace.current_workspace self.addCleanup(self.workspace.switch_to, initial_workspace) - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces) - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_hud_closes_on_spread(self): """This test shows that when the spread is initiated, the hud closes.""" # Need at least one application open for the spread to work. self.start_app_window("Calculator") - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.addCleanup(self.keybinding, "spread/cancel") self.keybinding("spread/start") - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_hud_closes_click_outside_geo_shrunk(self): """ @@ -250,86 +250,86 @@ class HudBehaviorTests(HudTestsBase): Shurnk is when the hud has no results and is much smaller then normal. """ - self.hud.ensure_visible() - (x,y,w,h) = self.hud.view.geometry + self.unity.hud.ensure_visible() + (x,y,w,h) = self.unity.hud.view.geometry self.mouse.move(w/2, h-50) self.mouse.click() - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_hud_closes_click_outside_geo(self): """Clicking outside of the hud will make it close.""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("Test") - (x,y,w,h) = self.hud.view.geometry + (x,y,w,h) = self.unity.hud.view.geometry self.mouse.move(w/2, h+50) self.mouse.click() - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_hud_closes_click_after_text_removed(self): """Clicking outside of the hud after a search text has been entered and then removed from the searchbox will make it close.""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("Test") self.keyboard.press_and_release("Escape") - (x,y,w,h) = self.hud.view.geometry + (x,y,w,h) = self.unity.hud.view.geometry self.mouse.move(w/2, h+50) self.mouse.click() - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_alt_f4_close_hud(self): """Hud must close on alt+F4.""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.press_and_release("Alt+F4") - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_alt_f4_close_hud_with_capslock_on(self): """Hud must close on Alt+F4 even when the capslock is turned on.""" self.keyboard.press_and_release("Caps_Lock") self.addCleanup(self.keyboard.press_and_release, "Caps_Lock") - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.press_and_release("Alt+F4") - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_app_activate_on_enter(self): """Hud must close after activating a search item with Enter.""" self.start_app('Text Editor', locale='C') self.addCleanup(self.close_all_app, "Text Editor") - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("File > Quit") - self.assertThat(self.hud.search_string, Eventually(Equals("File > Quit"))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals("File > Quit"))) self.keyboard.press_and_release("Enter") self.assertFalse(self.app_is_running("Text Editor")) - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_hud_closes_on_escape(self): """Hud must close on escape after searchbox is cleared""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("ThisText") self.keyboard.press_and_release("Escape") self.keyboard.press_and_release("Escape") - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_hud_closes_on_escape_shrunk(self): """Hud must close when escape key is pressed""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.press_and_release("Escape") - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_alt_arrow_keys_not_eaten(self): """Tests that Alt+ArrowKey events are correctly passed to the @@ -368,62 +368,62 @@ class HudBehaviorTests(HudTestsBase): change the selected button from 1 to 5. """ - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("a") - (x,y,w,h) = self.hud.view.geometry + (x,y,w,h) = self.unity.hud.view.geometry # Specify a slower rate so that HUD can register the mouse movement properly self.mouse.move(w/2, 0, rate=5) - self.assertThat(self.hud.view.selected_button, Eventually(Equals(1))) + self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(1))) self.mouse.move(w/2, h, rate=5) - self.assertThat(self.hud.view.selected_button, Eventually(Equals(5))) + self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(5))) def test_keyboard_steals_focus_from_mouse(self): """This tests moves the mouse from the top of the screen to the bottom, then it presses the keyboard up 5 times, this must change the selected button from 5 to 1. """ - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.keyboard.type("a") - (x,y,w,h) = self.hud.view.geometry + (x,y,w,h) = self.unity.hud.view.geometry self.mouse.move(w/2, 0) self.mouse.move(w/2, h) - self.assertThat(self.hud.view.selected_button, Eventually(Equals(5))) + self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(5))) for i in range(5): self.keyboard.press_and_release('Up') - self.assertThat(self.hud.view.selected_button, Eventually(Equals(1))) + self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(1))) def test_keep_focus_on_application_opens(self): """The Hud must keep key focus as well as stay open if an app gets opened from an external source. """ - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.start_app_window("Calculator") sleep(1) self.keyboard.type("HasFocus") - self.assertThat(self.hud.search_string, Eventually(Equals("HasFocus"))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals("HasFocus"))) def test_closes_mouse_down_outside(self): """Test that a mouse down outside of the hud closes the hud.""" - self.hud.ensure_visible() - current_monitor = self.hud.monitor + self.unity.hud.ensure_visible() + current_monitor = self.unity.hud.monitor - (x,y,w,h) = self.hud.geometry + (x,y,w,h) = self.unity.hud.geometry (screen_x,screen_y,screen_w,screen_h) = self.screen_geo.get_monitor_geometry(current_monitor) self.mouse.move(x + w + (screen_w-((screen_x-x)+w))/2, y + h + (screen_h-((screen_y-y)+h))/2) self.mouse.click() - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_closes_then_focuses_window_on_mouse_down(self): """If 2 windows are open with 1 maximized and the non-maxmized @@ -435,7 +435,7 @@ class HudBehaviorTests(HudTestsBase): self.keybinding("window/maximize") self.start_app("Calculator") - self.hud.ensure_visible() + self.unity.hud.ensure_visible() #Click bottom right of the screen w = self.screen_geo.get_screen_width() @@ -454,8 +454,8 @@ class HudBehaviorTests(HudTestsBase): self.keybinding("switcher/reveal_normal") self.assertProperty(char_win, is_active=True) - self.hud.ensure_visible() - self.hud.ensure_hidden() + self.unity.hud.ensure_visible() + self.unity.hud.ensure_hidden() self.assertProperty(char_win, is_active=True) @@ -481,7 +481,7 @@ class HudLauncherInteractionsTests(HudTestsBase): apps as active. """ - launcher = self.launcher.get_launcher_for_monitor(self.hud_monitor) + launcher = self.unity.launcher.get_launcher_for_monitor(self.hud_monitor) # We need an app to switch to: self.start_app('Character Map') @@ -495,11 +495,11 @@ class HudLauncherInteractionsTests(HudTestsBase): # reveal and hide hud several times over: for i in range(3): - self.hud.ensure_visible() - self.hud.ensure_hidden() + self.unity.hud.ensure_visible() + self.unity.hud.ensure_hidden() # click application icons for running apps in the launcher: - icon = self.launcher.model.get_icon(desktop_id="gucharmap.desktop") + icon = self.unity.launcher.model.get_icon(desktop_id="gucharmap.desktop") launcher.click_launcher_icon(icon) # see how many apps are marked as being active: @@ -509,10 +509,10 @@ class HudLauncherInteractionsTests(HudTestsBase): def test_hud_does_not_change_launcher_status(self): """Opening the HUD must not change the launcher visibility.""" - launcher = self.launcher.get_launcher_for_monitor(self.hud_monitor) + launcher = self.unity.launcher.get_launcher_for_monitor(self.hud_monitor) launcher_shows_pre = launcher.is_showing - self.hud.ensure_visible() + self.unity.hud.ensure_visible() launcher_shows_post = launcher.is_showing self.assertThat(launcher_shows_pre, Equals(launcher_shows_post)) @@ -533,14 +533,14 @@ class HudLockedLauncherInteractionsTests(HudTestsBase): def test_hud_launcher_icon_hides_bfb(self): """BFB icon must be hidden when the HUD launcher icon is shown.""" - hud_icon = self.hud.get_launcher_icon() - bfb_icon = self.launcher.model.get_bfb_icon() + hud_icon = self.unity.hud.get_launcher_icon() + bfb_icon = self.unity.launcher.model.get_bfb_icon() self.assertThat(bfb_icon.visible, Eventually(Equals(True))) self.assertTrue(bfb_icon.is_on_monitor(self.hud_monitor)) self.assertThat(hud_icon.visible, Eventually(Equals(False))) - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.assertThat(hud_icon.visible, Eventually(Equals(True))) self.assertTrue(hud_icon.is_on_monitor(self.hud_monitor)) @@ -550,9 +550,9 @@ class HudLockedLauncherInteractionsTests(HudTestsBase): def test_hud_desaturates_launcher_icons(self): """Launcher icons must desaturate when the HUD is opened.""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() - for icon in self.launcher.model.get_launcher_icons_for_monitor(self.hud_monitor): + for icon in self.unity.launcher.model.get_launcher_icons_for_monitor(self.hud_monitor): if isinstance(icon, HudLauncherIcon): self.assertThat(icon.desaturated, Eventually(Equals(False))) else: @@ -561,13 +561,13 @@ class HudLockedLauncherInteractionsTests(HudTestsBase): def test_hud_launcher_icon_click_hides_hud(self): """Clicking the Hud Icon should hide the HUD""" - hud_icon = self.hud.get_launcher_icon() - self.hud.ensure_visible() + hud_icon = self.unity.hud.get_launcher_icon() + self.unity.hud.ensure_visible() - launcher = self.launcher.get_launcher_for_monitor(self.hud_monitor) + launcher = self.unity.launcher.get_launcher_for_monitor(self.hud_monitor) launcher.click_launcher_icon(hud_icon) - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) self.assertThat(hud_icon.visible, Eventually(Equals(False))) @@ -591,22 +591,22 @@ class HudVisualTests(HudTestsBase): sleep(0.5) def test_initially_hidden(self): - self.assertFalse(self.hud.visible) + self.assertFalse(self.unity.hud.visible) def test_hud_is_on_right_monitor(self): """HUD must be drawn on the monitor where the mouse is.""" - self.hud.ensure_visible() - self.assertThat(self.hud.monitor, Eventually(Equals(self.hud_monitor))) - self.assertTrue(self.screen_geo.is_rect_on_monitor(self.hud.monitor, self.hud.geometry)) + self.unity.hud.ensure_visible() + self.assertThat(self.unity.hud.monitor, Eventually(Equals(self.hud_monitor))) + self.assertTrue(self.screen_geo.is_rect_on_monitor(self.unity.hud.monitor, self.unity.hud.geometry)) def test_hud_geometries(self): """Tests the HUD geometries for the given monitor and status.""" - self.hud.ensure_visible() + self.unity.hud.ensure_visible() monitor_geo = self.screen_geo.get_monitor_geometry(self.hud_monitor) monitor_x = monitor_geo[0] monitor_w = monitor_geo[2] - hud_x = self.hud.geometry[0] - hud_w = self.hud.geometry[2] + hud_x = self.unity.hud.geometry[0] + hud_w = self.unity.hud.geometry[2] if self.hud_locked: self.assertThat(hud_x, GreaterThan(monitor_x)) @@ -618,16 +618,16 @@ class HudVisualTests(HudTestsBase): def test_hud_is_locked_to_launcher(self): """Tests if the HUD is locked to launcher as we expect or not.""" - self.hud.ensure_visible() - self.assertThat(self.hud.is_locked_launcher, Eventually(Equals(self.hud_locked))) + self.unity.hud.ensure_visible() + self.assertThat(self.unity.hud.is_locked_launcher, Eventually(Equals(self.hud_locked))) def test_hud_icon_is_shown(self): """Tests that the correct HUD icon is shown.""" - self.hud.ensure_visible() - hud_launcher_icon = self.hud.get_launcher_icon() - hud_embedded_icon = self.hud.get_embedded_icon() + self.unity.hud.ensure_visible() + hud_launcher_icon = self.unity.hud.get_launcher_icon() + hud_embedded_icon = self.unity.hud.get_embedded_icon() - if self.hud.is_locked_launcher: + if self.unity.hud.is_locked_launcher: self.assertThat(hud_launcher_icon.visible, Eventually(Equals(True))) self.assertTrue(hud_launcher_icon.is_on_monitor(self.hud_monitor)) self.assertTrue(hud_launcher_icon.active) @@ -645,18 +645,18 @@ class HudVisualTests(HudTestsBase): self.close_all_app("Calculator") calc = self.start_app("Calculator") self.assertTrue(calc.is_active) - self.hud.ensure_visible() + self.unity.hud.ensure_visible() - self.assertThat(self.hud.icon.icon_name, Eventually(Equals(calc.icon))) + self.assertThat(self.unity.hud.icon.icon_name, Eventually(Equals(calc.icon))) def test_hud_icon_shows_the_ubuntu_emblem_on_empty_desktop(self): """When in 'show desktop' mode the hud icon must be the BFB icon.""" self.start_placeholder_app() - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) - self.hud.ensure_visible() + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) + self.unity.hud.ensure_visible() - self.assertThat(self.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png"))) + self.assertThat(self.unity.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png"))) def test_switch_dash_hud_does_not_break_the_focused_application_emblem(self): """Switching from Dash to HUD must still show the correct HUD icon.""" @@ -664,10 +664,10 @@ class HudVisualTests(HudTestsBase): calc = self.start_app("Calculator") self.assertTrue(calc.is_active) - self.dash.ensure_visible() - self.hud.ensure_visible() + self.unity.dash.ensure_visible() + self.unity.hud.ensure_visible() - self.assertThat(self.hud.icon.icon_name, Eventually(Equals(calc.icon))) + self.assertThat(self.unity.hud.icon.icon_name, Eventually(Equals(calc.icon))) def test_switch_hud_dash_does_not_break_the_focused_application_emblem(self): """Switching from HUD to Dash and back must still show the correct HUD icon.""" @@ -675,10 +675,10 @@ class HudVisualTests(HudTestsBase): calc = self.start_app("Calculator") self.assertTrue(calc.is_active) - self.hud.ensure_visible() - self.dash.ensure_visible() - self.hud.ensure_visible() - self.assertThat(self.hud.icon.icon_name, Eventually(Equals(calc.icon))) + self.unity.hud.ensure_visible() + self.unity.dash.ensure_visible() + self.unity.hud.ensure_visible() + self.assertThat(self.unity.hud.icon.icon_name, Eventually(Equals(calc.icon))) def test_dash_hud_only_uses_icon_from_current_desktop(self): """ @@ -691,16 +691,16 @@ class HudVisualTests(HudTestsBase): self.start_placeholder_app() initial_workspace = self.workspace.current_workspace self.addCleanup(self.workspace.switch_to, initial_workspace) - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) calc = self.start_app("Calculator") self.assertTrue(calc.is_active) self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces) - self.dash.ensure_visible() - self.hud.ensure_visible() + self.unity.dash.ensure_visible() + self.unity.hud.ensure_visible() - self.assertThat(self.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png"))) + self.assertThat(self.unity.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png"))) class HudAlternativeKeybindingTests(HudTestsBase): @@ -710,14 +710,14 @@ class HudAlternativeKeybindingTests(HudTestsBase): self.set_unity_option("show_hud", "<Super>h") # Don't use reveal_hud, but be explicit in the keybindings. self.keyboard.press_and_release("Super+h") - self.assertThat(self.hud.visible, Eventually(Equals(True))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_ctrl_alt_h(self): """Test hud reveal on <Contrl><Alt>h.""" self.set_unity_option("show_hud", "<Control><Alt>h") # Don't use reveal_hud, but be explicit in the keybindings. self.keyboard.press_and_release("Ctrl+Alt+h") - self.assertThat(self.hud.visible, Eventually(Equals(True))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) class HudCrossMonitorsTests(HudTestsBase): @@ -733,27 +733,27 @@ class HudCrossMonitorsTests(HudTestsBase): the keyboard is used. The hud must not move to that monitor. """ - current_monitor = self.hud.ideal_monitor + current_monitor = self.unity.hud.ideal_monitor - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.screen_geo.move_mouse_to_monitor((current_monitor + 1) % self.screen_geo.get_num_monitors()) self.keyboard.type("abc") - self.assertThat(self.hud.ideal_monitor, Eventually(Equals(current_monitor))) + self.assertThat(self.unity.hud.ideal_monitor, Eventually(Equals(current_monitor))) def test_hud_close_on_cross_monitor_click(self): """Hud must close when clicking on a window in a different screen.""" - self.addCleanup(self.hud.ensure_hidden) + self.addCleanup(self.unity.hud.ensure_hidden) for monitor in range(self.screen_geo.get_num_monitors()-1): self.screen_geo.move_mouse_to_monitor(monitor) - self.hud.ensure_visible() + self.unity.hud.ensure_visible() self.screen_geo.move_mouse_to_monitor(monitor+1) sleep(.5) self.mouse.click() - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) diff --git a/tests/autopilot/unity/tests/test_ibus.py b/tests/autopilot/unity/tests/test_ibus.py index 400807f97..eeb57707d 100644 --- a/tests/autopilot/unity/tests/test_ibus.py +++ b/tests/autopilot/unity/tests/test_ibus.py @@ -20,8 +20,6 @@ from autopilot.emulators.ibus import ( from autopilot.matchers import Eventually from autopilot.testcase import multiply_scenarios from testtools.matchers import Equals, NotEquals -from unity.emulators.dash import Dash -from unity.emulators.hud import Hud from unity.tests import UnityTestCase @@ -94,13 +92,13 @@ class IBusWidgetScenariodTests(IBusTests): # Use lambdas here so we don't require DBus service at module import time. scenarios = [ - ('dash', {'widget': lambda: Dash()}), - ('hud', {'widget': lambda: Hud()}) + ('dash', {'widget': 'dash'}), + ('hud', {'widget': 'hud'}) ] def do_ibus_test(self): """Do the basic IBus test on self.widget using self.input and self.result.""" - widget = self.widget() + widget = getattr(self.unity, self.widget) widget.ensure_visible() self.addCleanup(widget.ensure_hidden) self.activate_ibus(widget.searchbar) @@ -195,26 +193,26 @@ class IBusTestsPinyinIgnore(IBusTests): self.activate_input_engine_or_skip(self.engine_name) def test_ignore_key_events_on_dash(self): - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) - self.activate_ibus(self.dash.searchbar) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) + self.activate_ibus(self.unity.dash.searchbar) self.keyboard.type("cipan") self.keyboard.press_and_release("Tab") self.keyboard.type(" ") - self.deactivate_ibus(self.dash.searchbar) - self.assertThat(self.dash.search_string, Eventually(NotEquals(" "))) + self.deactivate_ibus(self.unity.dash.searchbar) + self.assertThat(self.unity.dash.search_string, Eventually(NotEquals(" "))) def test_ignore_key_events_on_hud(self): - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type("a") - self.activate_ibus(self.hud.searchbar) + self.activate_ibus(self.unity.hud.searchbar) self.keyboard.type("riqi") - old_selected = self.hud.selected_button + old_selected = self.unity.hud.selected_button self.keyboard.press_and_release("Down") - new_selected = self.hud.selected_button - self.deactivate_ibus(self.hud.searchbar) + new_selected = self.unity.hud.selected_button + self.deactivate_ibus(self.unity.hud.searchbar) self.assertEqual(old_selected, new_selected) @@ -230,26 +228,26 @@ class IBusTestsAnthyIgnore(IBusTests): self.activate_input_engine_or_skip(self.engine_name) def test_ignore_key_events_on_dash(self): - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) - self.activate_ibus(self.dash.searchbar) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) + self.activate_ibus(self.unity.dash.searchbar) self.keyboard.type("shisutemu ") self.keyboard.press_and_release("Tab") self.keyboard.press_and_release("Ctrl+j") - self.deactivate_ibus(self.dash.searchbar) - dash_search_string = self.dash.search_string + self.deactivate_ibus(self.unity.dash.searchbar) + dash_search_string = self.unity.dash.search_string self.assertNotEqual("", dash_search_string) def test_ignore_key_events_on_hud(self): - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type("a") - self.activate_ibus(self.hud.searchbar) + self.activate_ibus(self.unity.hud.searchbar) self.keyboard.type("hiduke") - old_selected = self.hud.selected_button + old_selected = self.unity.hud.selected_button self.keyboard.press_and_release("Down") - new_selected = self.hud.selected_button - self.deactivate_ibus(self.hud.searchbar) + new_selected = self.unity.hud.selected_button + self.deactivate_ibus(self.unity.hud.searchbar) self.assertEqual(old_selected, new_selected) diff --git a/tests/autopilot/unity/tests/test_panel.py b/tests/autopilot/unity/tests/test_panel.py index 2c6b12f54..a8aeb1f98 100644 --- a/tests/autopilot/unity/tests/test_panel.py +++ b/tests/autopilot/unity/tests/test_panel.py @@ -43,7 +43,7 @@ class PanelTestsBase(UnityTestCase): def setUp(self): super(PanelTestsBase, self).setUp() - self.panel = self.panels.get_panel_for_monitor(self.panel_monitor) + self.panel = self.unity.panels.get_panel_for_monitor(self.panel_monitor) self.panel.move_mouse_below_the_panel() self.addCleanup(self.panel.move_mouse_below_the_panel) @@ -156,8 +156,8 @@ class PanelTitleTests(PanelTestsBase): """With no windows shown, the panel must display the default title.""" gettext.install("unity", unicode=True) self.start_placeholder_app() - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) self.assertThat(self.panel.desktop_is_active, Eventually(Equals(True))) self.assertThat(self.panel.title, Equals(_("Ubuntu Desktop"))) @@ -200,8 +200,8 @@ class PanelTitleTests(PanelTestsBase): text_win = self.open_new_application_window("Text Editor", maximized=True) self.open_new_application_window("Calculator", maximized=False) - icon = self.launcher.model.get_icon(desktop_id=text_win.application.desktop_file) - launcher = self.launcher.get_launcher_for_monitor(self.panel_monitor) + icon = self.unity.launcher.model.get_icon(desktop_id=text_win.application.desktop_file) + launcher = self.unity.launcher.get_launcher_for_monitor(self.panel_monitor) launcher.click_launcher_icon(icon) self.assertProperty(text_win, is_focused=True) @@ -224,9 +224,9 @@ class PanelTitleTests(PanelTestsBase): text_win = self.open_new_application_window("Text Editor") current_title = self.panel.title - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) - self.switcher.next_icon() + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) + self.unity.switcher.next_icon() self.assertThat(self.panel.title, Eventually(Equals(current_title))) @@ -245,8 +245,8 @@ class PanelWindowButtonsTests(PanelTestsBase): def test_window_buttons_dont_show_on_empty_desktop(self): """Tests that the window buttons are not shown on clean desktop.""" self.start_placeholder_app() - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False))) @@ -292,8 +292,8 @@ class PanelWindowButtonsTests(PanelTestsBase): def test_window_buttons_show_with_dash(self): """Window buttons must be shown when the dash is open.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True))) self.assertWinButtonsInOverlayMode(True) @@ -303,29 +303,29 @@ class PanelWindowButtonsTests(PanelTestsBase): buttons must still work in the dash.""" self.set_unity_option("icon_size", 25) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) - desired_max = not self.dash.view.dash_maximized + desired_max = not self.unity.dash.view.dash_maximized if desired_max: self.panel.window_buttons.maximize.mouse_click() else: self.panel.window_buttons.unmaximize.mouse_click() - self.assertThat(self.dash.view.dash_maximized, Eventually(Equals(desired_max))) + self.assertThat(self.unity.dash.view.dash_maximized, Eventually(Equals(desired_max))) def test_window_buttons_show_with_hud(self): """Window buttons must be shown when the HUD is open.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True))) self.assertWinButtonsInOverlayMode(True) def test_window_buttons_update_visual_state(self): """Window button must update its state in response to mouse events.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) button = self.panel.window_buttons.close self.assertThat(button.visual_state, Eventually(Equals("normal"))) @@ -341,8 +341,8 @@ class PanelWindowButtonsTests(PanelTestsBase): """Window buttons must ignore clicks when the mouse released outside their area. """ - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) button = self.panel.window_buttons.close button.mouse_move_to() @@ -352,7 +352,7 @@ class PanelWindowButtonsTests(PanelTestsBase): self.mouse.release() self.assertThat(button.visual_state, Eventually(Equals("normal"))) - self.assertThat(self.hud.visible, Eventually(Equals(True))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_window_buttons_close_button_works_for_window(self): """Close window button must actually closes a window.""" @@ -441,43 +441,43 @@ class PanelWindowButtonsTests(PanelTestsBase): def test_window_buttons_close_button_works_for_hud(self): """Tests that the window 'Close' actually closes the HUD.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.panel.window_buttons.close.mouse_click() - self.assertThat(self.hud.visible, Eventually(Equals(False))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(False))) def test_minimize_button_disabled_for_hud(self): """Minimize button must be disabled for the HUD.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.assertThat(self.panel.window_buttons.minimize.enabled, Eventually(Equals(False))) def test_minimize_button_does_nothing_for_hud(self): """Minimize button must not affect the Hud.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.panel.window_buttons.minimize.mouse_click() - self.assertThat(self.hud.visible, Eventually(Equals(True))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_maximize_button_disabled_for_hud(self): """Maximize button must be disabled for the HUD.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.assertThat(self.panel.window_buttons.maximize.enabled, Eventually(Equals(False))) def test_maximize_button_does_nothing_for_hud(self): """Maximize button must not affect the Hud.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.panel.window_buttons.maximize.mouse_click() - self.assertThat(self.hud.visible, Eventually(Equals(True))) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_hud_maximize_button_does_not_change_dash_form_factor(self): """Clicking on the 'Maximize' button of the HUD must not change the dash @@ -485,39 +485,39 @@ class PanelWindowButtonsTests(PanelTestsBase): See bug #939054 """ - inital_form_factor = self.dash.view.form_factor - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + inital_form_factor = self.unity.dash.view.form_factor + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.panel.window_buttons.maximize.mouse_click() # long sleep here to make sure that any change that might happen will # have already happened. sleep(5) - self.assertThat(self.dash.view.form_factor, Equals(inital_form_factor)) + self.assertThat(self.unity.dash.view.form_factor, Equals(inital_form_factor)) def test_window_buttons_close_button_works_for_dash(self): """Tests that the window 'Close' actually closes the Dash.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.panel.window_buttons.close.mouse_click() - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_minimize_button_disabled_for_dash(self): """Tests that the 'Minimize' button is disabled for the dash.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.assertThat(self.panel.window_buttons.minimize.enabled, Eventually(Equals(False))) def test_minimize_button_does_nothing_for_dash(self): """Tests that the 'Minimize' button is disabled for the dash.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.panel.window_buttons.minimize.mouse_click() sleep(5) - self.assertThat(self.dash.visible, Eventually(Equals(True))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) def test_window_buttons_maximization_buttons_works_for_dash(self): """'Maximize' and 'Restore' buttons (when both enabled) must work as expected.""" @@ -529,14 +529,14 @@ class PanelWindowButtonsTests(PanelTestsBase): # this test out and make it suck less. # # For your sanity I have annotated it with comments. - self.dash.ensure_visible() + self.unity.dash.ensure_visible() self.addCleanup(self.panel.window_buttons.close.mouse_click) unmaximize = self.panel.window_buttons.unmaximize maximize = self.panel.window_buttons.maximize # "netbook" means "dash is maximised" - dash_maximised = (self.dash.view.form_factor == "netbook") + dash_maximised = (self.unity.dash.view.form_factor == "netbook") # this if statement will trigger only when we're on very small screens, # where it doesn't make sense to have the dash anything other than @@ -545,7 +545,7 @@ class PanelWindowButtonsTests(PanelTestsBase): unmaximize.mouse_click() # nice long sleep to make sure that any changes have time to process. sleep(5) - self.assertThat(self.dash.view.form_factor, Equals("netbook")) + self.assertThat(self.unity.dash.view.form_factor, Equals("netbook")) else: # we are able to resize the dash. # maximise and unmaximise (restore) buttons are shown in the same place @@ -571,9 +571,9 @@ class PanelWindowButtonsTests(PanelTestsBase): self.assertThat(active_button.visible, Eventually(Equals(False))) if dash_maximised: - self.assertThat(self.dash.view.form_factor, Eventually(Equals("desktop"))) + self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("desktop"))) else: - self.assertThat(self.dash.view.form_factor, Eventually(Equals("netbook"))) + self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("netbook"))) self.addCleanup(active_button.mouse_click) inactive_button.mouse_click() @@ -582,9 +582,9 @@ class PanelWindowButtonsTests(PanelTestsBase): self.assertThat(inactive_button.visible, Eventually(Equals(False))) if dash_maximised: - self.assertThat(self.dash.view.form_factor, Eventually(Equals("netbook"))) + self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("netbook"))) else: - self.assertThat(self.dash.view.form_factor, Eventually(Equals("desktop"))) + self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("desktop"))) def test_minimize_button_disabled_for_non_minimizable_windows(self): """Minimize button must be disabled for windows that don't support minimization.""" @@ -645,14 +645,14 @@ class PanelWindowButtonsTests(PanelTestsBase): you must still be able to type into the Hud. """ - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type("Hello") self.panel.window_buttons.minimize.mouse_click() self.keyboard.type("World") - self.assertThat(self.hud.search_string, Eventually(Equals("HelloWorld"))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals("HelloWorld"))) def test_double_click_unmaximize_window(self): """Double clicking the grab area must unmaximize a maximized window.""" @@ -915,8 +915,8 @@ class PanelMenuTests(PanelTestsBase): def test_menus_dont_show_with_dash(self): """Tests that menus are not showing when opening the dash.""" self.open_new_application_window("Text Editor", maximized=True) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.assertThat(self.panel.menus_shown, Eventually(Equals(False))) @@ -924,8 +924,8 @@ class PanelMenuTests(PanelTestsBase): def test_menus_dont_show_with_hud(self): """Tests that menus are not showing when opening the HUD.""" self.open_new_application_window("Text Editor", maximized=True) - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.assertThat(self.panel.menus_shown, Eventually(Equals(False))) @@ -985,13 +985,13 @@ class PanelIndicatorEntryTests(PanelTestsBase): """When the dash is open and a click is on an indicator the dash must close and the indicator must open. """ - self.dash.ensure_visible() + self.unity.dash.ensure_visible() indicator = self.panel.indicators.get_indicator_by_name_hint("indicator-session") self.mouse_open_indicator(indicator) self.assertThat(indicator.active, Eventually(Equals(True))) - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) class PanelKeyNavigationTests(PanelTestsBase): @@ -1130,15 +1130,15 @@ class PanelGrabAreaTests(PanelTestsBase): def test_panels_dont_steal_keynav_foucs_from_hud(self): """On a mouse click event on the panel you must still be able to type into the Hud.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type("Hello") self.move_mouse_over_grab_area() self.mouse.click() self.keyboard.type("World") - self.assertThat(self.hud.search_string, Eventually(Equals("HelloWorld"))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals("HelloWorld"))) class PanelCrossMonitorsTests(PanelTestsBase): @@ -1159,10 +1159,10 @@ class PanelCrossMonitorsTests(PanelTestsBase): self.screen_geo.drag_window_to_monitor(calc_win, monitor) if prev_monitor: - prev_panel = self.panels.get_panel_for_monitor(prev_monitor) + prev_panel = self.unity.panels.get_panel_for_monitor(prev_monitor) self.assertThat(prev_panel.active, Eventually(Equals(False))) - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) self.assertThat(panel.active, Eventually(Equals(True))) self.assertThat(panel.title, Eventually(Equals(calc_win.application.name))) @@ -1176,7 +1176,7 @@ class PanelCrossMonitorsTests(PanelTestsBase): self.sleep_menu_settle_period() for monitor in range(0, self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) panel.move_mouse_over_window_buttons() self.sleep_menu_settle_period() @@ -1190,13 +1190,13 @@ class PanelCrossMonitorsTests(PanelTestsBase): """Window buttons must not show on the panels other than the one where the dash is opened. """ - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) for monitor in range(0, self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) - if self.dash.monitor == monitor: + if self.unity.dash.monitor == monitor: self.assertThat(panel.window_buttons_shown, Eventually(Equals(True))) else: self.assertThat(panel.window_buttons_shown, Eventually(Equals(False))) @@ -1205,13 +1205,13 @@ class PanelCrossMonitorsTests(PanelTestsBase): """Window buttons must not show on the panels other than the one where the hud is opened. """ - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) for monitor in range(0, self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) - if self.hud.monitor == monitor: + if self.unity.hud.monitor == monitor: self.assertThat(panel.window_buttons_shown, Eventually(Equals(True))) else: self.assertThat(panel.window_buttons_shown, Eventually(Equals(False))) @@ -1225,7 +1225,7 @@ class PanelCrossMonitorsTests(PanelTestsBase): text_win = self.open_new_application_window("Text Editor", maximized=True) for monitor in range(self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) if monitor != text_win.monitor: panel.window_buttons.close.mouse_move_to() @@ -1241,7 +1241,7 @@ class PanelCrossMonitorsTests(PanelTestsBase): text_win = self.open_new_application_window("Text Editor", maximized=True) for monitor in range(self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) if monitor != text_win.monitor: panel.window_buttons.minimize.mouse_click() @@ -1256,7 +1256,7 @@ class PanelCrossMonitorsTests(PanelTestsBase): text_win = self.open_new_application_window("Text Editor", maximized=True) for monitor in range(0, self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) if monitor != text_win.monitor: panel.window_buttons.unmaximize.mouse_click() @@ -1265,12 +1265,12 @@ class PanelCrossMonitorsTests(PanelTestsBase): def test_hovering_indicators_on_multiple_monitors(self): """Opening an indicator entry and then hovering others entries must open them.""" text_win = self.open_new_application_window("Text Editor") - panel = self.panels.get_panel_for_monitor(text_win.monitor) + panel = self.unity.panels.get_panel_for_monitor(text_win.monitor) indicator = panel.indicators.get_indicator_by_name_hint("indicator-session") self.mouse_open_indicator(indicator) for monitor in range(0, self.screen_geo.get_num_monitors()): - panel = self.panels.get_panel_for_monitor(monitor) + panel = self.unity.panels.get_panel_for_monitor(monitor) entries = panel.get_indicator_entries(include_hidden_menus=True) self.assertThat(len(entries), GreaterThan(0)) diff --git a/tests/autopilot/unity/tests/test_quicklist.py b/tests/autopilot/unity/tests/test_quicklist.py index 2ca1271a7..bf6224a76 100644 --- a/tests/autopilot/unity/tests/test_quicklist.py +++ b/tests/autopilot/unity/tests/test_quicklist.py @@ -32,7 +32,7 @@ class QuicklistActionTests(UnityTestCase): Returns the quicklist that was opened. """ - launcher = self.launcher.get_launcher_for_monitor(0) + launcher = self.unity.launcher.get_launcher_for_monitor(0) launcher.click_launcher_icon(launcher_icon, button=3) self.addCleanup(self.keyboard.press_and_release, "Escape") self.assertThat(launcher_icon.get_quicklist, Eventually(NotEquals(None))) @@ -47,7 +47,7 @@ class QuicklistActionTests(UnityTestCase): desktop_file = os.path.join('/usr/share/applications', desktop_id) de = DesktopEntry(desktop_file) # get the launcher icon from the launcher: - launcher_icon = self.launcher.model.get_icon(desktop_id=desktop_id) + launcher_icon = self.unity.launcher.model.get_icon(desktop_id=desktop_id) self.assertThat(launcher_icon, NotEquals(None)) # open the icon quicklist, and get all the text labels: @@ -78,9 +78,9 @@ class QuicklistActionTests(UnityTestCase): self.assertVisibleWindowStack([char_win2, calc_win, char_win1]) - char_icon = self.launcher.model.get_icon( + char_icon = self.unity.launcher.model.get_icon( desktop_id=char_win1.application.desktop_file) - calc_icon = self.launcher.model.get_icon( + calc_icon = self.unity.launcher.model.get_icon( desktop_id=calc_win.application.desktop_file) calc_ql = self.open_quicklist_for_icon(calc_icon) @@ -106,15 +106,15 @@ class QuicklistActionTests(UnityTestCase): self.assertVisibleWindowStack([char_win2, char_win1]) self.assertProperty(char_win2, is_focused=True) - char_icon = self.launcher.model.get_icon(desktop_id=char_app.desktop_file) + char_icon = self.unity.launcher.model.get_icon(desktop_id=char_app.desktop_file) char_ql = self.open_quicklist_for_icon(char_icon) app_item = char_ql.get_quicklist_application_item(char_app.name) self.addCleanup(self.keybinding, "spread/cancel") app_item.mouse_click() - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) - self.assertThat(self.window_manager.scale_active_for_group, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active_for_group, Eventually(Equals(True))) def test_quicklist_item_triggered_closes_dash(self): """When any quicklist item is triggered it must close the dash.""" @@ -122,38 +122,38 @@ class QuicklistActionTests(UnityTestCase): calc_win = self.start_app_window("Calculator") self.assertProperty(calc_win, is_focused=True) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) - calc_icon = self.launcher.model.get_icon( + calc_icon = self.unity.launcher.model.get_icon( desktop_id=calc_win.application.desktop_file) self.open_quicklist_for_icon(calc_icon) self.keyboard.press_and_release("Down") self.keyboard.press_and_release("Enter") - self.assertThat(self.dash.visible, Eventually(Equals(False))) + self.assertThat(self.unity.dash.visible, Eventually(Equals(False))) def test_quicklist_closes_when_hud_opens(self): """When a quicklist is open you must still be able to open the Hud.""" calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) + calc_icon = self.unity.launcher.model.get_icon(desktop_id=calc.desktop_file) self.open_quicklist_for_icon(calc_icon) - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) - self.assertThat(self.hud.visible, Eventually(Equals(True))) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_quicklist_closes_when_dash_opens(self): """When the quicklist is open you must still be able to open the dash.""" calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) + calc_icon = self.unity.launcher.model.get_icon(desktop_id=calc.desktop_file) self.open_quicklist_for_icon(calc_icon) - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) - self.assertThat(self.dash.visible, Eventually(Equals(True))) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) + self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) def test_right_click_opens_quicklist_if_already_open(self): """A right click to another icon in the launcher must @@ -165,9 +165,9 @@ class QuicklistActionTests(UnityTestCase): calc_win = self.start_app_window("Calculator") mahj_win = self.start_app_window("Mahjongg") - calc_icon = self.launcher.model.get_icon( + calc_icon = self.unity.launcher.model.get_icon( desktop_id=calc_win.application.desktop_file) - mahj_icon = self.launcher.model.get_icon( + mahj_icon = self.unity.launcher.model.get_icon( desktop_id=mahj_win.application.desktop_file) calc_ql = self.open_quicklist_for_icon(calc_icon) @@ -184,7 +184,7 @@ class QuicklistActionTests(UnityTestCase): calc_win = self.start_app_window("Calculator") - calc_icon = self.launcher.model.get_icon( + calc_icon = self.unity.launcher.model.get_icon( desktop_id=calc_win.application.desktop_file) calc_ql = self.open_quicklist_for_icon(calc_icon) @@ -201,7 +201,7 @@ class QuicklistKeyNavigationTests(UnityTestCase): super(QuicklistKeyNavigationTests, self).setUp() desktop_file = self.KNOWN_APPS["Text Editor"]["desktop-file"] - icon_refresh_fn = lambda : self.launcher.model.get_icon( + icon_refresh_fn = lambda : self.unity.launcher.model.get_icon( desktop_id=desktop_file) self.assertThat(icon_refresh_fn, Eventually(Equals(None))) @@ -210,7 +210,7 @@ class QuicklistKeyNavigationTests(UnityTestCase): self.assertThat(icon_refresh_fn, Eventually(NotEquals(None))) self.ql_launcher_icon = icon_refresh_fn() - self.ql_launcher = self.launcher.get_launcher_for_monitor(0) + self.ql_launcher = self.unity.launcher.get_launcher_for_monitor(0) def open_quicklist_with_mouse(self): """Opens a quicklist with the mouse.""" diff --git a/tests/autopilot/unity/tests/test_shopping_lens.py b/tests/autopilot/unity/tests/test_shopping_lens.py index 94d42a771..b808abb2a 100644 --- a/tests/autopilot/unity/tests/test_shopping_lens.py +++ b/tests/autopilot/unity/tests/test_shopping_lens.py @@ -29,13 +29,13 @@ class ShoppingLensTests(UnityTestCase): gettext.install("unity-lens-shopping") def tearDown(self): - self.dash.ensure_hidden() + self.unity.dash.ensure_hidden() super(ShoppingLensTests, self).tearDown() def test_no_results_in_home_lens_if_empty_search(self): """Test that the home lens contains no results if the search bar is empty.""" - self.dash.ensure_visible() - lens = self.dash.get_current_lens() + self.unity.dash.ensure_visible() + lens = self.unity.dash.get_current_lens() results_category = lens.get_category_by_name(_("More suggestions")) refresh_results_fn = lambda: len(results_category.get_results()) @@ -43,8 +43,8 @@ class ShoppingLensTests(UnityTestCase): def test_home_lens_has_shopping_results(self): """Test that the home lens contains results.""" - self.dash.ensure_visible() - lens = self.dash.get_current_lens() + self.unity.dash.ensure_visible() + lens = self.unity.dash.get_current_lens() self.keyboard.type("playstation") results_category = lens.get_category_by_name(_("More suggestions")) @@ -54,8 +54,8 @@ class ShoppingLensTests(UnityTestCase): def test_application_lens_has_shopping_results(self): """Test that the application lens contains results.""" - self.dash.reveal_application_lens() - lens = self.dash.get_current_lens() + self.unity.dash.reveal_application_lens() + lens = self.unity.dash.get_current_lens() self.keyboard.type("Text Editor") results_category = lens.get_category_by_name(_("More suggestions")) @@ -65,8 +65,8 @@ class ShoppingLensTests(UnityTestCase): def test_music_lens_has_shopping_results(self): """Test that the music lens contains results.""" - self.dash.reveal_music_lens() - lens = self.dash.get_current_lens() + self.unity.dash.reveal_music_lens() + lens = self.unity.dash.get_current_lens() self.keyboard.type("megadeth") results_category = lens.get_category_by_name(_("More suggestions")) @@ -76,8 +76,8 @@ class ShoppingLensTests(UnityTestCase): def test_preview_works_with_shopping_lens(self): """This test shows the dash preview works with shopping lens results.""" - self.dash.ensure_visible() - lens = self.dash.get_current_lens() + self.unity.dash.ensure_visible() + lens = self.unity.dash.get_current_lens() self.keyboard.type("playstation") results_category = lens.get_category_by_name(_("More suggestions")) @@ -88,14 +88,14 @@ class ShoppingLensTests(UnityTestCase): results = results_category.get_results() results[0].preview() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) def test_shopping_lens_preview_navigate_right(self): """This test shows that shopping lens results can open previews, then move to the next shopping result. """ - self.dash.ensure_visible() - lens = self.dash.get_current_lens() + self.unity.dash.ensure_visible() + lens = self.unity.dash.get_current_lens() self.keyboard.type("playstation") results_category = lens.get_category_by_name(_("More suggestions")) @@ -106,8 +106,8 @@ class ShoppingLensTests(UnityTestCase): results = results_category.get_results() results[0].preview() - self.assertThat(self.dash.preview_displaying, Eventually(Equals(True))) - self.preview_container = self.dash.view.get_preview_container() + self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) + self.preview_container = self.unity.dash.view.get_preview_container() start_index = self.preview_container.relative_nav_index self.preview_container.navigate_right() diff --git a/tests/autopilot/unity/tests/test_shortcut_hint.py b/tests/autopilot/unity/tests/test_shortcut_hint.py index 951de4d58..e92561858 100644 --- a/tests/autopilot/unity/tests/test_shortcut_hint.py +++ b/tests/autopilot/unity/tests/test_shortcut_hint.py @@ -25,7 +25,7 @@ class BaseShortcutHintTests(UnityTestCase): self.DEFAULT_WIDTH = 970; self.DEFAULT_HEIGHT = 680; - self.shortcut_hint = self.get_shortcut_controller() + #self.shortcut_hint = self.get_shortcut_controller() self.set_unity_option('shortcut_overlay', True) self.set_unity_log_level("unity.shell.compiz", "DEBUG") self.skip_if_monitor_too_small() @@ -36,23 +36,23 @@ class BaseShortcutHintTests(UnityTestCase): monitor_geo = self.screen_geo.get_monitor_geometry(monitor) monitor_w = monitor_geo[2] monitor_h = monitor_geo[3] - launcher_width = self.launcher.get_launcher_for_monitor(monitor).geometry[2] - panel_height = self.panels.get_panel_for_monitor(monitor).geometry[3] + launcher_width = self.unity.launcher.get_launcher_for_monitor(monitor).geometry[2] + panel_height = self.unity.panels.get_panel_for_monitor(monitor).geometry[3] if ((monitor_w - launcher_width) <= self.DEFAULT_WIDTH or (monitor_h - panel_height) <= self.DEFAULT_HEIGHT): self.skipTest("This test requires a bigger screen, to show the ShortcutHint") - def get_shortcut_controller(self): - controllers = ShortcutController.get_all_instances() - self.assertThat(len(controllers), Equals(1)) - return controllers[0] + # def get_shortcut_controller(self): + # controllers = ShortcutController.get_all_instances() + # self.assertThat(len(controllers), Equals(1)) + # return controllers[0] def get_launcher(self): # We could parameterise this so all tests run on both monitors (if MM is # set up), but I think it's fine to just always use monitor primary monitor: monitor = self.screen_geo.get_primary_monitor() - return self.launcher.get_launcher_for_monitor(monitor) + return self.unity.launcher.get_launcher_for_monitor(monitor) class ShortcutHintTests(BaseShortcutHintTests): @@ -60,39 +60,39 @@ class ShortcutHintTests(BaseShortcutHintTests): def test_shortcut_hint_reveal(self): """Test that the shortcut hint is shown.""" - self.shortcut_hint.show() - self.addCleanup(self.shortcut_hint.ensure_hidden) - self.assertThat(self.shortcut_hint.visible, Eventually(Equals(True))) + self.unity.shortcut_hint.show() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) + self.assertThat(self.unity.shortcut_hint.visible, Eventually(Equals(True))) def test_shortcut_hint_reveal_timeout(self): """Shortcut hint must be shown after a sufficient timeout.""" - timeout = self.shortcut_hint.get_show_timeout() - self.shortcut_hint.show() - self.addCleanup(self.shortcut_hint.ensure_hidden) + timeout = self.unity.shortcut_hint.get_show_timeout() + self.unity.shortcut_hint.show() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) sleep(timeout/2.0) - self.assertThat(self.shortcut_hint.visible, Equals(False)) + self.assertThat(self.unity.shortcut_hint.visible, Equals(False)) # This should happen after 3/4 of 'timeout': - self.assertThat(self.shortcut_hint.visible, Eventually(Equals(True))) + self.assertThat(self.unity.shortcut_hint.visible, Eventually(Equals(True))) def test_shortcut_hint_unreveal(self): """Shortcut hint must hide when keys are released.""" - self.shortcut_hint.ensure_visible() - self.shortcut_hint.hide() - self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False))) + self.unity.shortcut_hint.ensure_visible() + self.unity.shortcut_hint.hide() + self.assertThat(self.unity.shortcut_hint.visible, Eventually(Equals(False))) def test_shortcut_hint_cancel(self): """Shortcut hint must hide when cancelled.""" - self.shortcut_hint.ensure_visible() - self.shortcut_hint.cancel() - self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False))) + self.unity.shortcut_hint.ensure_visible() + self.unity.shortcut_hint.cancel() + self.assertThat(self.unity.shortcut_hint.visible, Eventually(Equals(False))) def test_shortcut_hint_no_blur(self): """""" - self.shortcut_hint.ensure_visible() - self.addCleanup(self.shortcut_hint.ensure_hidden) + self.unity.shortcut_hint.ensure_visible() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) - self.assertThat(self.shortcut_hint.get_shortcut_view().bg_texture_is_valid, Eventually(Equals(True))) + self.assertThat(self.unity.shortcut_hint.get_shortcut_view().bg_texture_is_valid, Eventually(Equals(True))) class ShortcutHintInteractionsTests(BaseShortcutHintTests): @@ -100,39 +100,39 @@ class ShortcutHintInteractionsTests(BaseShortcutHintTests): def test_shortcut_hint_hide_using_unity_shortcuts(self): """Unity shortcuts (like expo) must hide the shortcut hint.""" - self.shortcut_hint.ensure_visible() - self.addCleanup(self.shortcut_hint.ensure_hidden) + self.unity.shortcut_hint.ensure_visible() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) self.keybinding_tap("expo/start") self.addCleanup(self.keybinding, "expo/cancel") def test_shortcut_hint_hide_pressing_modifiers(self): """Pressing a modifer key must hide the shortcut hint.""" - self.shortcut_hint.ensure_visible() - self.addCleanup(self.shortcut_hint.ensure_hidden) + self.unity.shortcut_hint.ensure_visible() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) self.keyboard.press('Control') - self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False))) + self.assertThat(self.unity.shortcut_hint.visible, Eventually(Equals(False))) def test_launcher_switcher_next_doesnt_show_shortcut_hint(self): """Super+Tab switcher cycling forward must not show shortcut hint.""" - switcher_timeout = self.shortcut_hint.get_show_timeout() - self.shortcut_hint.show() - self.addCleanup(self.shortcut_hint.ensure_hidden) + switcher_timeout = self.unity.shortcut_hint.get_show_timeout() + self.unity.shortcut_hint.show() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) self.keybinding("launcher/switcher/next") self.keybinding("launcher/switcher/next") self.addCleanup(self.keyboard.press_and_release, "Escape") sleep(switcher_timeout * 2) - self.assertThat(self.shortcut_hint.visible, Equals(False)) + self.assertThat(self.unity.shortcut_hint.visible, Equals(False)) def test_launcher_switcher_prev_doesnt_show_shortcut_hint(self): """Super+Tab switcher cycling backwards must not show shortcut hint.""" - switcher_timeout = self.shortcut_hint.get_show_timeout() - self.shortcut_hint.show() - self.addCleanup(self.shortcut_hint.ensure_hidden) + switcher_timeout = self.unity.shortcut_hint.get_show_timeout() + self.unity.shortcut_hint.show() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) self.keybinding("launcher/switcher/next") self.addCleanup(self.keyboard.press_and_release, "Escape") @@ -140,7 +140,7 @@ class ShortcutHintInteractionsTests(BaseShortcutHintTests): self.keybinding("launcher/switcher/prev") sleep(switcher_timeout * 2) - self.assertThat(self.shortcut_hint.visible, Equals(False)) + self.assertThat(self.unity.shortcut_hint.visible, Equals(False)) def test_launcher_icons_hints_show_with_shortcut_hint(self): """When the shortcut hint is shown also the launcer's icons hints should @@ -148,10 +148,10 @@ class ShortcutHintInteractionsTests(BaseShortcutHintTests): """ launcher = self.get_launcher() - self.shortcut_hint.ensure_visible() - self.addCleanup(self.shortcut_hint.ensure_hidden) + self.unity.shortcut_hint.ensure_visible() + self.addCleanup(self.unity.shortcut_hint.ensure_hidden) - self.assertThat(self.shortcut_hint.visible, Equals(True)) + self.assertThat(self.unity.shortcut_hint.visible, Equals(True)) self.assertThat(launcher.shortcuts_shown, Equals(True)) def test_shortcut_hint_shows_with_launcher_icons_hints(self): @@ -164,4 +164,4 @@ class ShortcutHintInteractionsTests(BaseShortcutHintTests): self.addCleanup(launcher.keyboard_unreveal_launcher) self.assertThat(launcher.shortcuts_shown, Eventually(Equals(True))) - self.assertThat(self.shortcut_hint.visible, Eventually(Equals(True))) + self.assertThat(self.unity.shortcut_hint.visible, Eventually(Equals(True))) diff --git a/tests/autopilot/unity/tests/test_showdesktop.py b/tests/autopilot/unity/tests/test_showdesktop.py index e6469fb77..64f42595a 100644 --- a/tests/autopilot/unity/tests/test_showdesktop.py +++ b/tests/autopilot/unity/tests/test_showdesktop.py @@ -11,6 +11,7 @@ from __future__ import absolute_import from testtools import skip from time import sleep +from unity.emulators.switcher import SwitcherDirection from unity.tests import UnityTestCase @@ -35,8 +36,8 @@ class ShowDesktopTests(UnityTestCase): test_windows = self.launch_test_apps() # show desktop, verify all windows are hidden: - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) for win in test_windows: self.assertProperty(win, is_valid=True) @@ -47,15 +48,15 @@ class ShowDesktopTests(UnityTestCase): test_windows = self.launch_test_apps() # show desktop, verify all windows are hidden: - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) for win in test_windows: self.assertProperty(win, is_valid=True) self.assertProperty(win, is_hidden=True) # un-show desktop, verify all windows are shown: - self.window_manager.leave_show_desktop() + self.unity.window_manager.leave_show_desktop() for win in test_windows: self.assertProperty(win, is_valid=True) @@ -66,17 +67,17 @@ class ShowDesktopTests(UnityTestCase): charmap, calc = self.launch_test_apps() # show desktop, verify all windows are hidden: - self.window_manager.enter_show_desktop() - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.window_manager.enter_show_desktop() + self.addCleanup(self.unity.window_manager.leave_show_desktop) for win in (charmap, calc): self.assertProperty(win, is_valid=True) self.assertProperty(win, is_hidden=True) # We'll un-minimise the character map - find it's launcherIcon in the launcher: - charmap_icon = self.launcher.model.get_icon(desktop_id="gucharmap.desktop") + charmap_icon = self.unity.launcher.model.get_icon(desktop_id="gucharmap.desktop") if charmap_icon: - self.launcher.get_launcher_for_monitor(0).click_launcher_icon(charmap_icon) + self.unity.launcher.get_launcher_for_monitor(0).click_launcher_icon(charmap_icon) else: self.fail("Could not find launcher icon in launcher.") @@ -84,7 +85,7 @@ class ShowDesktopTests(UnityTestCase): self.assertProperty(calc, is_hidden=True) # hide desktop - now all windows should be visible: - self.window_manager.leave_show_desktop() + self.unity.window_manager.leave_show_desktop() for win in (charmap, calc): self.assertProperty(win, is_hidden=False) @@ -95,9 +96,9 @@ class ShowDesktopTests(UnityTestCase): test_windows = self.launch_test_apps() # show desktop, verify all windows are hidden: - self.switcher.initiate() - self.switcher.select_icon(self.switcher.DIRECTION_BACKWARDS, tooltip_text="Show Desktop") - self.addCleanup(self.window_manager.leave_show_desktop) + self.unity.switcher.initiate() + self.unity.switcher.select_icon(SwitcherDirection.BACKWARDS, tooltip_text="Show Desktop") + self.addCleanup(self.unity.window_manager.leave_show_desktop) self.switcher.select() for win in test_windows: diff --git a/tests/autopilot/unity/tests/test_spread.py b/tests/autopilot/unity/tests/test_spread.py index 9636b6de6..99d545de3 100644 --- a/tests/autopilot/unity/tests/test_spread.py +++ b/tests/autopilot/unity/tests/test_spread.py @@ -38,21 +38,21 @@ class SpreadTests(UnityTestCase): """Initiate the Spread for all windows""" self.addCleanup(self.keybinding, "spread/cancel") self.keybinding("spread/start") - self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) def initiate_spread_for_application(self, desktop_id): """Initiate the Spread for windows of the given app""" - icon = self.launcher.model.get_icon(desktop_id=desktop_id) + icon = self.unity.launcher.model.get_icon(desktop_id=desktop_id) self.assertThat(icon, NotEquals(None)) - launcher = self.launcher.get_launcher_for_monitor(self.screen_geo.get_primary_monitor()) + launcher = self.unity.launcher.get_launcher_for_monitor(self.screen_geo.get_primary_monitor()) self.addCleanup(self.keybinding, "spread/cancel") launcher.click_launcher_icon(icon) - self.assertThat(self.window_manager.scale_active_for_group, Eventually(Equals(True))) + self.assertThat(self.unity.window_manager.scale_active_for_group, Eventually(Equals(True))) def assertWindowIsNotScaled(self, xid): """Assert that a window is not scaled""" - refresh_fn = lambda: xid in [w.xid for w in self.screen.scaled_windows] + refresh_fn = lambda: xid in [w.xid for w in self.unity.screen.scaled_windows] self.assertThat(refresh_fn, Eventually(Equals(False))) def assertWindowIsClosed(self, xid): @@ -68,8 +68,8 @@ class SpreadTests(UnityTestCase): [win1, win2] = self.start_test_application_windows("Calculator") self.initiate_spread_for_application(win1.application.desktop_file) - self.assertThat(lambda: len(self.screen.scaled_windows), Eventually(Equals(2))) - self.assertThat(lambda: (win1.x_id and win2.x_id) in [w.xid for w in self.screen.scaled_windows], + self.assertThat(lambda: len(self.unity.screen.scaled_windows), Eventually(Equals(2))) + self.assertThat(lambda: (win1.x_id and win2.x_id) in [w.xid for w in self.unity.screen.scaled_windows], Eventually(Equals(True))) def test_scaled_window_is_focused_on_click(self): @@ -80,7 +80,7 @@ class SpreadTests(UnityTestCase): not_focused = [w for w in windows if not w.is_focused][0] target_xid = not_focused.x_id - [target_win] = [w for w in self.screen.scaled_windows if w.xid == target_xid] + [target_win] = [w for w in self.unity.screen.scaled_windows if w.xid == target_xid] (x, y, w, h) = target_win.geometry self.mouse.move(x + w / 2, y + h / 2) @@ -95,7 +95,7 @@ class SpreadTests(UnityTestCase): self.initiate_spread_for_application(win.application.desktop_file) target_xid = win.x_id - [target_win] = [w for w in self.screen.scaled_windows if w.xid == target_xid] + [target_win] = [w for w in self.unity.screen.scaled_windows if w.xid == target_xid] (x, y, w, h) = target_win.geometry self.mouse.move(x + w / 2, y + h / 2) @@ -111,7 +111,7 @@ class SpreadTests(UnityTestCase): self.initiate_spread_for_screen() target_xid = win.x_id - [target_win] = [w for w in self.screen.scaled_windows if w.xid == target_xid] + [target_win] = [w for w in self.unity.screen.scaled_windows if w.xid == target_xid] (x, y, w, h) = target_win.scale_close_geometry self.mouse.move(x + w / 2, y + h / 2) diff --git a/tests/autopilot/unity/tests/test_switcher.py b/tests/autopilot/unity/tests/test_switcher.py index cdb78e2a1..e86db7b1e 100644 --- a/tests/autopilot/unity/tests/test_switcher.py +++ b/tests/autopilot/unity/tests/test_switcher.py @@ -14,7 +14,7 @@ import logging from testtools.matchers import Equals, Contains, Not from time import sleep -from unity.emulators.switcher import Switcher, SwitcherMode +from unity.emulators.switcher import SwitcherDirection, SwitcherMode from unity.tests import UnityTestCase logger = logging.getLogger(__name__) @@ -34,7 +34,7 @@ class SwitcherTestCase(UnityTestCase): if type(state) is not bool: raise TypeError("'state' must be boolean, not %r" % type(state)) self.set_unity_option("disable_show_desktop", state) - self.assertThat(self.switcher.controller.show_desktop_disabled, Eventually(Equals(state))) + self.assertThat(self.unity.switcher.show_desktop_disabled, Eventually(Equals(state))) def set_timeout_setting(self, state): if type(state) is not bool: @@ -79,90 +79,90 @@ class SwitcherTests(SwitcherTestCase): """Switcher must start in normal (i.e.- not details) mode.""" self.start_app("Character Map") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) - self.assertProperty(self.switcher, mode=SwitcherMode.NORMAL) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) + self.assertProperty(self.unity.switcher, mode=SwitcherMode.NORMAL) def test_label_matches_application_name(self): """The switcher label must match the selected application name in normal mode.""" windows = self.start_applications() - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) for win in windows: app_name = win.application.name - self.switcher.select_icon(Switcher.DIRECTION_FORWARDS, tooltip_text=app_name) - self.assertThat(self.switcher.label_visible, Eventually(Equals(True))) - self.assertThat(self.switcher.label, Eventually(Equals(app_name))) + self.unity.switcher.select_icon(SwitcherDirection.FORWARDS, tooltip_text=app_name) + self.assertThat(self.unity.switcher.label_visible, Eventually(Equals(True))) + self.assertThat(self.unity.switcher.label, Eventually(Equals(app_name))) def test_application_window_is_fake_decorated(self): """When the switcher is in details mode must not show the focused window title.""" window = self.start_app_window("Text Editor") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - self.switcher.select_icon(Switcher.DIRECTION_BACKWARDS, tooltip_text=window.application.name) + self.unity.switcher.select_icon(SwitcherDirection.BACKWARDS, tooltip_text=window.application.name) - self.switcher.show_details() - self.assertThat(self.switcher.label_visible, Eventually(Equals(False))) - self.assertThat(self.screen.window(window.x_id).fake_decorated, Eventually(Equals(True))) + self.unity.switcher.show_details() + self.assertThat(self.unity.switcher.label_visible, Eventually(Equals(False))) + self.assertThat(self.unity.screen.window(window.x_id).fake_decorated, Eventually(Equals(True))) def test_application_window_is_fake_decorated_in_detail_mode(self): """Starting switcher in details mode must not show the focused window title.""" window = self.start_app_window("Text Editor") - self.switcher.initiate(SwitcherMode.DETAIL) - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate(SwitcherMode.DETAIL) + self.addCleanup(self.unity.switcher.terminate) - self.assertThat(self.switcher.label_visible, Eventually(Equals(False))) - self.assertThat(self.screen.window(window.x_id).fake_decorated, Eventually(Equals(True))) + self.assertThat(self.unity.switcher.label_visible, Eventually(Equals(False))) + self.assertThat(self.unity.screen.window(window.x_id).fake_decorated, Eventually(Equals(True))) def test_switcher_move_next(self): """Test that pressing the next icon binding moves to the next icon""" self.start_applications() - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - start = self.switcher.selection_index - self.switcher.next_icon() + start = self.unity.switcher.selection_index + self.unity.switcher.next_icon() # Allow for wrap-around to first icon in switcher - next_index = (start + 1) % len(self.switcher.icons) + next_index = (start + 1) % len(self.unity.switcher.icons) - self.assertThat(self.switcher.selection_index, Eventually(Equals(next_index))) + self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(next_index))) def test_switcher_move_prev(self): """Test that pressing the previous icon binding moves to the previous icon""" self.start_applications() - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - start = self.switcher.selection_index - self.switcher.previous_icon() + start = self.unity.switcher.selection_index + self.unity.switcher.previous_icon() - self.assertThat(self.switcher.selection_index, Eventually(Equals(start - 1))) + self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(start - 1))) def test_switcher_scroll_next(self): """Test that scrolling the mouse wheel down moves to the next icon""" self.start_applications() - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - start = self.switcher.selection_index - self.switcher.next_via_mouse() + start = self.unity.switcher.selection_index + self.unity.switcher.next_via_mouse() # Allow for wrap-around to first icon in switcher - next_index = (start + 1) % len(self.switcher.icons) + next_index = (start + 1) % len(self.unity.switcher.icons) - self.assertThat(self.switcher.selection_index, Eventually(Equals(next_index))) + self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(next_index))) def test_switcher_scroll_prev(self): """Test that scrolling the mouse wheel up moves to the previous icon""" self.start_applications() - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - start = self.switcher.selection_index - self.switcher.previous_via_mouse() + start = self.unity.switcher.selection_index + self.unity.switcher.previous_via_mouse() - self.assertThat(self.switcher.selection_index, Eventually(Equals(start - 1))) + self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(start - 1))) def test_switcher_arrow_key_does_not_init(self): """Ensure that Alt+Right does not initiate switcher. @@ -171,7 +171,7 @@ class SwitcherTests(SwitcherTestCase): """ self.keyboard.press_and_release('Alt+Right') - self.assertThat(self.switcher.visible, Equals(False)) + self.assertThat(self.unity.switcher.visible, Equals(False)) def test_lazy_switcher_initiate(self): """Inserting a long delay between the Alt press and the Tab tab must still @@ -182,22 +182,22 @@ class SwitcherTests(SwitcherTestCase): self.keybinding_hold("switcher/reveal_normal") self.addCleanup(self.keybinding_release, "switcher/reveal_normal") - self.assertThat(self.switcher.visible, Eventually(Equals(False))) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(False))) sleep(5) self.keybinding_tap("switcher/reveal_normal") self.addCleanup(self.keybinding, "switcher/cancel") - self.assertThat(self.switcher.visible, Eventually(Equals(True))) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(True))) def test_switcher_cancel(self): """Pressing the switcher cancel keystroke must cancel the switcher.""" self.start_app("Character Map") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - self.assertThat(self.switcher.visible, Eventually(Equals(True))) - self.switcher.cancel() - self.assertThat(self.switcher.visible, Eventually(Equals(False))) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(True))) + self.unity.switcher.cancel() + self.assertThat(self.unity.switcher.visible, Eventually(Equals(False))) def test_lazy_switcher_cancel(self): """Must be able to cancel the switcher after a 'lazy' initiation.""" @@ -205,12 +205,12 @@ class SwitcherTests(SwitcherTestCase): self.keybinding_hold("switcher/reveal_normal") self.addCleanup(self.keybinding_release, "switcher/reveal_normal") - self.assertThat(self.switcher.visible, Eventually(Equals(False))) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(False))) sleep(5) self.keybinding_tap("switcher/reveal_normal") - self.assertThat(self.switcher.visible, Eventually(Equals(True))) - self.switcher.cancel() - self.assertThat(self.switcher.visible, Eventually(Equals(False))) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(True))) + self.unity.switcher.cancel() + self.assertThat(self.unity.switcher.visible, Eventually(Equals(False))) def test_switcher_appears_on_monitor_with_mouse(self): """Tests that the switches appears on the correct monitor. @@ -229,17 +229,18 @@ class SwitcherTests(SwitcherTestCase): for monitor in range(num_monitors): self.screen_geo.move_mouse_to_monitor(monitor) - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) - self.assertThat(self.switcher.controller.monitor, Eventually(Equals(monitor))) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) + self.assertThat(self.unity.switcher.monitor, Eventually(Equals(monitor))) def test_switcher_alt_f4_is_disabled(self): """Tests that alt+f4 does not work while switcher is active.""" win = self.start_app_window("Text Editor") - self.switcher.initiate(SwitcherMode.DETAIL) - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(True))) self.keyboard.press_and_release("Alt+F4") # Need the sleep to allow the window time to close, for jenkins! @@ -315,11 +316,11 @@ class SwitcherDetailsTests(SwitcherTestCase): self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces) self.start_applications("Character Map", "Character Map", "Mahjongg") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) # Wait longer than details mode. sleep(3) - self.assertProperty(self.switcher, mode=SwitcherMode.DETAIL) + self.assertProperty(self.unity.switcher, mode=SwitcherMode.DETAIL) def test_no_details_for_apps_on_different_workspace(self): """Tests that details mode does not initiates when there are multiple windows @@ -336,11 +337,11 @@ class SwitcherDetailsTests(SwitcherTestCase): self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces) self.start_applications("Character Map", "Mahjongg") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) # Wait longer than details mode. sleep(3) - self.assertProperty(self.switcher, mode=SwitcherMode.NORMAL) + self.assertProperty(self.unity.switcher, mode=SwitcherMode.NORMAL) class SwitcherDetailsModeTests(SwitcherTestCase): @@ -366,12 +367,12 @@ class SwitcherDetailsModeTests(SwitcherTestCase): """ self.start_app_window("Character Map") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) self.keyboard.press_and_release(self.initiate_keycode) - self.assertProperty(self.switcher, mode=SwitcherMode.DETAIL) + self.assertProperty(self.unity.switcher, mode=SwitcherMode.DETAIL) def test_next_icon_from_last_detail_works(self): """Pressing next while showing last switcher item in details mode @@ -379,19 +380,19 @@ class SwitcherDetailsModeTests(SwitcherTestCase): """ self.start_app("Character Map") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) - while self.switcher.selection_index < len(self.switcher.icons) - 1: - self.switcher.next_icon() + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) + while self.unity.switcher.selection_index < len(self.unity.switcher.icons) - 1: + self.unity.switcher.next_icon() self.keyboard.press_and_release(self.initiate_keycode) sleep(0.5) # Make sure we're at the end of the details list for this icon - possible_details = self.switcher.detail_current_count - 1 - while self.switcher.detail_selection_index < possible_details: - self.switcher.next_detail() + possible_details = self.unity.switcher.detail_current_count - 1 + while self.unity.switcher.detail_selection_index < possible_details: + self.unity.switcher.next_detail() - self.switcher.next_icon() - self.assertThat(self.switcher.selection_index, Eventually(Equals(0))) + self.unity.switcher.next_icon() + self.assertThat(self.unity.switcher.selection_index, Eventually(Equals(0))) def test_detail_mode_selects_last_active_window(self): """The active selection in detail mode must be the last focused window. @@ -400,12 +401,12 @@ class SwitcherDetailsModeTests(SwitcherTestCase): char_win1, char_win2 = self.start_applications("Character Map", "Character Map") self.assertVisibleWindowStack([char_win2, char_win1]) - self.switcher.initiate() - while self.switcher.current_icon.tooltip_text != char_win2.application.name: - self.switcher.next_icon() + self.unity.switcher.initiate() + while self.unity.switcher.current_icon.tooltip_text != char_win2.application.name: + self.unity.switcher.next_icon() self.keyboard.press_and_release(self.initiate_keycode) sleep(0.5) - self.switcher.select() + self.unity.switcher.select() self.assertProperty(char_win1, is_focused=True) @@ -416,10 +417,10 @@ class SwitcherDetailsModeTests(SwitcherTestCase): char_win1, char_win2, char_win3 = self.start_applications("Character Map", "Character Map", "Character Map") self.assertVisibleWindowStack([char_win3, char_win2, char_win1]) - self.switcher.initiate(SwitcherMode.DETAIL) - self.switcher.next_detail() + self.unity.switcher.initiate(SwitcherMode.DETAIL) + self.unity.switcher.next_detail() - self.switcher.select() + self.unity.switcher.select() self.assertVisibleWindowStack([char_win1, char_win3, char_win2]) @@ -440,10 +441,10 @@ class SwitcherWorkspaceTests(SwitcherTestCase): self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces) char_map = self.start_app("Character Map") - self.switcher.initiate() - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate() + self.addCleanup(self.unity.switcher.terminate) - get_icon_names = lambda: [i.tooltip_text for i in self.switcher.icons] + get_icon_names = lambda: [i.tooltip_text for i in self.unity.switcher.icons] self.assertThat(get_icon_names, Eventually(Contains(char_map.name))) self.assertThat(get_icon_names, Eventually(Not(Contains(calc.name)))) @@ -456,10 +457,10 @@ class SwitcherWorkspaceTests(SwitcherTestCase): self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces) char_map = self.start_app("Character Map") - self.switcher.initiate(SwitcherMode.ALL) - self.addCleanup(self.switcher.terminate) + self.unity.switcher.initiate(SwitcherMode.ALL) + self.addCleanup(self.unity.switcher.terminate) - get_icon_names = lambda: [i.tooltip_text for i in self.switcher.icons] + get_icon_names = lambda: [i.tooltip_text for i in self.unity.switcher.icons] self.assertThat(get_icon_names, Eventually(Contains(calc.name))) self.assertThat(get_icon_names, Eventually(Contains(char_map.name))) @@ -485,10 +486,10 @@ class SwitcherWorkspaceTests(SwitcherTestCase): self.start_app("Calculator") - self.switcher.initiate() - while self.switcher.current_icon.tooltip_text != char_win2.application.name: - self.switcher.next_icon() - self.switcher.select() + self.unity.switcher.initiate() + while self.unity.switcher.current_icon.tooltip_text != char_win2.application.name: + self.unity.switcher.next_icon() + self.unity.switcher.select() self.assertProperty(char_win2, is_hidden=False) @@ -503,6 +504,6 @@ class SwitcherWorkspaceTests(SwitcherTestCase): self.addCleanup(self.keyboard.release, "Ctrl+Alt+Right") sleep(1) self.keybinding_hold_part_then_tap("switcher/reveal_normal") - self.addCleanup(self.switcher.terminate) + self.addCleanup(self.unity.switcher.terminate) - self.assertThat(self.switcher.visible, Eventually(Equals(False))) + self.assertThat(self.unity.switcher.visible, Eventually(Equals(False))) diff --git a/tests/autopilot/unity/tests/xim/test_gcin.py b/tests/autopilot/unity/tests/xim/test_gcin.py index 3a5adacbc..936b99f38 100644 --- a/tests/autopilot/unity/tests/xim/test_gcin.py +++ b/tests/autopilot/unity/tests/xim/test_gcin.py @@ -54,19 +54,19 @@ class GcinTestHangul(GcinTestCase): def test_dash_input(self): """Entering an input string through gcin will result in a Korean string result in the dash.""" - self.dash.ensure_visible() - self.addCleanup(self.dash.ensure_hidden) + self.unity.dash.ensure_visible() + self.addCleanup(self.unity.dash.ensure_hidden) self.enter_hangul_mode() self.keyboard.type(self.input) - self.assertThat(self.dash.search_string, Eventually(Equals(self.result))) + self.assertThat(self.unity.dash.search_string, Eventually(Equals(self.result))) def test_hud_input(self): """Entering an input string through gcin will result in a Korean string result in the hud.""" - self.hud.ensure_visible() - self.addCleanup(self.hud.ensure_hidden) + self.unity.hud.ensure_visible() + self.addCleanup(self.unity.hud.ensure_hidden) self.enter_hangul_mode() self.keyboard.type(self.input) - self.assertThat(self.hud.search_string, Eventually(Equals(self.result))) + self.assertThat(self.unity.hud.search_string, Eventually(Equals(self.result))) diff --git a/tests/mock-application.h b/tests/mock-application.h index cabc82ae1..aafa0a2d6 100644 --- a/tests/mock-application.h +++ b/tests/mock-application.h @@ -25,9 +25,45 @@ namespace testmocks { -class MockApplication : public unity::Application +struct MockApplicationWindow : unity::ApplicationWindow +{ + MockApplicationWindow(Window xid) + : xid_(xid) + , monitor_(0) + , type_("window") + , visible_(true) + , active_(false) + , urgent_(false) + { + visible.SetGetterFunction([this] { return visible_; }); + active.SetGetterFunction([this] { return active_; }); + urgent.SetGetterFunction([this] { return urgent_; }); + } + + Window xid_; + int monitor_; + std::string title_; + std::string icon_; + std::string type_; + + bool visible_; + bool active_; + bool urgent_; + + virtual std::string title() const { return title_; } + virtual std::string icon() const { return icon_; } + virtual std::string type() const { return type_; } + + virtual Window window_id() const { return xid_; } + virtual int monitor() const { return monitor_; } + + virtual unity::ApplicationPtr application() const { return unity::ApplicationPtr(); } + virtual bool Focus() const { return false; } + virtual void Quit() const {} +}; + +struct MockApplication : unity::Application { -public: MockApplication(std::string const& desktop_file, std::string const& icon = "", std::string const& title = "") @@ -51,6 +87,7 @@ public: urgent.SetGetterFunction(sigc::mem_fun(this, &MockApplication::GetUrgent)); } + unity::WindowList window_list_; std::string desktop_file_; std::string icon_; std::string title_; @@ -67,7 +104,7 @@ public: virtual std::string type() const { return "mock"; } virtual std::string repr() const { return "MockApplication"; } - virtual unity::WindowList GetWindows() const { return unity::WindowList(); } + virtual unity::WindowList GetWindows() const { return window_list_; } virtual bool OwnsWindow(Window window_id) const { return false; } virtual std::vector<std::string> GetSupportedMimeTypes() const { return {}; } @@ -98,6 +135,14 @@ public: return false; } + void SetActiveState(bool state) + { + if (active_ == state) + return; + active_ = state; + active.changed.emit(state); + } + bool GetVisible() const { return visible_; } bool GetActive() const { return active_; } bool GetRunning() const { return running_; } diff --git a/tests/test_application_launcher_icon.cpp b/tests/test_application_launcher_icon.cpp index f409473d9..5c5122b2d 100644 --- a/tests/test_application_launcher_icon.cpp +++ b/tests/test_application_launcher_icon.cpp @@ -28,7 +28,7 @@ #include "ApplicationLauncherIcon.h" #include "FavoriteStore.h" #include "mock-application.h" - +#include "StandaloneWindowManager.h" using namespace unity; using namespace testmocks; @@ -45,6 +45,7 @@ class TestApplicationLauncherIcon : public testing::Test public: virtual void SetUp() { + WM = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()); usc_app.reset(new MockApplication(USC_DESKTOP, "softwarecenter")); usc_icon = new launcher::ApplicationLauncherIcon(usc_app); ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP); @@ -58,6 +59,7 @@ public: ASSERT_TRUE(mock_icon->DesktopFile().empty()); } + StandaloneWindowManager* WM; std::shared_ptr<MockApplication> usc_app; std::shared_ptr<MockApplication> empty_app; std::shared_ptr<MockApplication> mock_app; @@ -165,4 +167,17 @@ TEST_F(TestApplicationLauncherIcon, InvalidIconUpdatesOnRunning) EXPECT_EQ(mock_icon->icon_name(), "icon-name"); } +TEST_F(TestApplicationLauncherIcon, ActiveQuirkWMCrossCheck) +{ + auto win = std::make_shared<MockApplicationWindow>(g_random_int()); + mock_app->window_list_ = { win }; + ASSERT_FALSE(mock_icon->IsActive()); + + mock_app->SetActiveState(true); + ASSERT_FALSE(mock_icon->IsActive()); + + WM->AddStandaloneWindow(std::make_shared<StandaloneWindow>(win->window_id())); + EXPECT_TRUE(mock_icon->IsActive()); +} + } diff --git a/tests/test_switcher_model.cpp b/tests/test_switcher_model.cpp index b5e49adc6..9643a39ae 100644 --- a/tests/test_switcher_model.cpp +++ b/tests/test_switcher_model.cpp @@ -147,4 +147,15 @@ TEST_F(TestSwitcherModel, TestActiveDetailWindowSort) EXPECT_EQ(sorted, unsorted); } +TEST_F(TestSwitcherModel, SelectionIsActive) +{ + SwitcherModel model(icons_); + + model.Selection()->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, false); + EXPECT_FALSE(model.SelectionIsActive()); + + model.Selection()->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); + EXPECT_TRUE(model.SelectionIsActive()); +} + } diff --git a/unity-shared/BamfApplicationManager.cpp b/unity-shared/BamfApplicationManager.cpp index 8192265a8..ed8a0d881 100644 --- a/unity-shared/BamfApplicationManager.cpp +++ b/unity-shared/BamfApplicationManager.cpp @@ -68,7 +68,6 @@ bool View::GetVisible() const bool View::GetActive() const { return bamf_view_is_active(bamf_view_); - } bool View::GetRunning() const |
