diff options
| -rw-r--r-- | plugins/unityshell/src/AbstractLauncherIcon.h | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/DebugDBusInterface.cpp | 5 | ||||
| -rw-r--r-- | plugins/unityshell/src/DebugDBusInterface.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/DeviceLauncherIcon.cpp | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/DeviceLauncherIcon.h | 4 | ||||
| -rw-r--r-- | plugins/unityshell/src/DeviceLauncherSection.cpp | 123 | ||||
| -rw-r--r-- | plugins/unityshell/src/DeviceLauncherSection.h | 27 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherController.cpp | 13 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherController.h | 8 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherIcon.cpp | 6 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 46 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 12 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/emulators/unity/launcher.py | 11 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/test_launcher.py | 13 |
14 files changed, 127 insertions, 146 deletions
diff --git a/plugins/unityshell/src/AbstractLauncherIcon.h b/plugins/unityshell/src/AbstractLauncherIcon.h index fed3ab1a7..1cbcab329 100644 --- a/plugins/unityshell/src/AbstractLauncherIcon.h +++ b/plugins/unityshell/src/AbstractLauncherIcon.h @@ -217,6 +217,7 @@ public: sigc::signal<void, AbstractLauncherIcon::Ptr> needs_redraw; sigc::signal<void, AbstractLauncherIcon::Ptr> remove; + sigc::signal<void> visibility_changed; sigc::connection needs_redraw_connection; sigc::connection on_icon_added_connection; diff --git a/plugins/unityshell/src/DebugDBusInterface.cpp b/plugins/unityshell/src/DebugDBusInterface.cpp index 509ae4626..9d7a24971 100644 --- a/plugins/unityshell/src/DebugDBusInterface.cpp +++ b/plugins/unityshell/src/DebugDBusInterface.cpp @@ -94,13 +94,10 @@ GDBusInterfaceVTable DebugDBusInterface::interface_vtable = NULL }; -static CompScreen* _screen; static Introspectable* _parent_introspectable; -DebugDBusInterface::DebugDBusInterface(Introspectable* parent, - CompScreen* screen) +DebugDBusInterface::DebugDBusInterface(Introspectable* parent) { - _screen = screen; _parent_introspectable = parent; _owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, unity::DBUS_BUS_NAME.c_str(), diff --git a/plugins/unityshell/src/DebugDBusInterface.h b/plugins/unityshell/src/DebugDBusInterface.h index e82422c2b..3c11a5a0b 100644 --- a/plugins/unityshell/src/DebugDBusInterface.h +++ b/plugins/unityshell/src/DebugDBusInterface.h @@ -36,7 +36,7 @@ std::list<Introspectable*> GetIntrospectableNodesFromQuery(std::string const& qu class DebugDBusInterface { public: - DebugDBusInterface(Introspectable* introspectable, CompScreen* uscreen); + DebugDBusInterface(Introspectable* introspectable); ~DebugDBusInterface(); private: diff --git a/plugins/unityshell/src/DeviceLauncherIcon.cpp b/plugins/unityshell/src/DeviceLauncherIcon.cpp index ea91a565c..034e5c5e6 100644 --- a/plugins/unityshell/src/DeviceLauncherIcon.cpp +++ b/plugins/unityshell/src/DeviceLauncherIcon.cpp @@ -43,7 +43,7 @@ GduDevice* get_device_for_device_file (const gchar *device_file); } -DeviceLauncherIcon::DeviceLauncherIcon(GVolume* volume) +DeviceLauncherIcon::DeviceLauncherIcon(glib::Object<GVolume> const& volume) : SimpleLauncherIcon() , volume_(volume) , device_file_(g_volume_get_identifier(volume_, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE)) diff --git a/plugins/unityshell/src/DeviceLauncherIcon.h b/plugins/unityshell/src/DeviceLauncherIcon.h index 0665e6c5d..d6fcb51d7 100644 --- a/plugins/unityshell/src/DeviceLauncherIcon.h +++ b/plugins/unityshell/src/DeviceLauncherIcon.h @@ -36,7 +36,7 @@ class DeviceLauncherIcon : public SimpleLauncherIcon { public: - DeviceLauncherIcon(GVolume* volume); + DeviceLauncherIcon(glib::Object<GVolume> const& volume); void UpdateVisibility(int visibility = -1); void OnRemoved(); @@ -67,7 +67,7 @@ private: void ShowNotification(std::string const&, unsigned, GdkPixbuf*, std::string const&); private: - GVolume* volume_; + glib::Object<GVolume> volume_; glib::String device_file_; std::string name_; glib::Object<GduDevice> gdu_device_; diff --git a/plugins/unityshell/src/DeviceLauncherSection.cpp b/plugins/unityshell/src/DeviceLauncherSection.cpp index 2d9fed667..bbf1a7283 100644 --- a/plugins/unityshell/src/DeviceLauncherSection.cpp +++ b/plugins/unityshell/src/DeviceLauncherSection.cpp @@ -25,128 +25,101 @@ namespace launcher DeviceLauncherSection::DeviceLauncherSection() : monitor_(g_volume_monitor_get()) -{ - on_volume_added_handler_id_ = g_signal_connect(monitor_, - "volume-added", - G_CALLBACK(&DeviceLauncherSection::OnVolumeAdded), - this); - - on_volume_removed_handler_id_ = g_signal_connect(monitor_, - "volume-removed", - G_CALLBACK(&DeviceLauncherSection::OnVolumeRemoved), - this); - - on_mount_added_handler_id_ = g_signal_connect(monitor_, - "mount-added", - G_CALLBACK(&DeviceLauncherSection::OnMountAdded), - this); - - on_mount_pre_unmount_handler_id_ = g_signal_connect(monitor_, - "mount-pre-unmount", - G_CALLBACK(&DeviceLauncherSection::OnMountPreUnmount), - this); - - on_device_populate_entry_id_ = g_idle_add((GSourceFunc)&DeviceLauncherSection::PopulateEntries, this); +{ + typedef glib::Signal<void, GVolumeMonitor*, GVolume*> VolumeSignal; + sig_manager_.Add(new VolumeSignal(monitor_, "volume-added", sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeAdded))); + sig_manager_.Add(new VolumeSignal(monitor_, "volume-removed", sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeRemoved))); + + typedef glib::Signal<void, GVolumeMonitor*, GMount*> MountSignal; + sig_manager_.Add(new MountSignal(monitor_, "mount-added", sigc::mem_fun(this, &DeviceLauncherSection::OnMountAdded))); + sig_manager_.Add(new MountSignal(monitor_, "mount-pre-unmount", sigc::mem_fun(this, &DeviceLauncherSection::OnMountPreUnmount))); + + on_device_populate_entry_id_ = g_idle_add([] (gpointer data) { + auto self = static_cast<DeviceLauncherSection*>(data); + self->PopulateEntries(); + self->on_device_populate_entry_id_ = 0; + return FALSE; + }, this); } DeviceLauncherSection::~DeviceLauncherSection() { - if (on_volume_added_handler_id_) - g_signal_handler_disconnect((gpointer) monitor_, - on_volume_added_handler_id_); - - if (on_volume_removed_handler_id_) - g_signal_handler_disconnect((gpointer) monitor_, - on_volume_removed_handler_id_); - - if (on_mount_added_handler_id_) - g_signal_handler_disconnect((gpointer) monitor_, - on_mount_added_handler_id_); - - if (on_mount_pre_unmount_handler_id_) - g_signal_handler_disconnect((gpointer) monitor_, - on_mount_pre_unmount_handler_id_); - if (on_device_populate_entry_id_) g_source_remove(on_device_populate_entry_id_); } -bool DeviceLauncherSection::PopulateEntries(DeviceLauncherSection* self) +void DeviceLauncherSection::PopulateEntries() { - GList* volumes = g_volume_monitor_get_volumes(self->monitor_); + GList* volumes = g_volume_monitor_get_volumes(monitor_); for (GList* v = volumes; v; v = v->next) { - glib::Object<GVolume> volume((GVolume* )v->data); + if (!G_IS_VOLUME(v->data)) + continue; + + // This will unref the volume, since the list entries needs that. + // We'll keep a reference in the icon. + glib::Object<GVolume> volume(G_VOLUME(v->data)); DeviceLauncherIcon* icon = new DeviceLauncherIcon(volume); - self->map_[volume] = icon; - self->IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); + map_[volume] = icon; + IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); } g_list_free(volumes); - - self->on_device_populate_entry_id_ = 0; - - return false; } /* Uses a std::map to track all the volume icons shown and not shown. * Keep in mind: when "volume-removed" is recevied we should erase * the pair (GVolume - DeviceLauncherIcon) from the std::map to avoid leaks */ -void DeviceLauncherSection::OnVolumeAdded(GVolumeMonitor* monitor, - GVolume* volume, - DeviceLauncherSection* self) +void DeviceLauncherSection::OnVolumeAdded(GVolumeMonitor* monitor, GVolume* volume) { - DeviceLauncherIcon* icon = new DeviceLauncherIcon(volume); - - self->map_[volume] = icon; - self->IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); + // This just wraps the volume in a glib::Object, global ref_count is only + // temporary changed. + glib::Object<GVolume> gvolume(volume, glib::AddRef()); + DeviceLauncherIcon* icon = new DeviceLauncherIcon(gvolume); + + map_[gvolume] = icon; + IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); } -void DeviceLauncherSection::OnVolumeRemoved(GVolumeMonitor* monitor, - GVolume* volume, - DeviceLauncherSection* self) +void DeviceLauncherSection::OnVolumeRemoved(GVolumeMonitor* monitor, GVolume* volume) { + auto volume_it = map_.find(volume); + // It should not happen! Let me do the check anyway. - if (self->map_.find(volume) != self->map_.end()) - { - self->map_[volume]->OnRemoved(); - self->map_.erase(volume); + if (volume_it != map_.end()) + { + volume_it->second->OnRemoved(); + map_.erase(volume_it); } } /* Keep in mind: we could have a GMount without a related GVolume * so check everything to avoid unwanted behaviors. */ -void DeviceLauncherSection::OnMountAdded(GVolumeMonitor* monitor, - GMount* mount, - DeviceLauncherSection* self) +void DeviceLauncherSection::OnMountAdded(GVolumeMonitor* monitor, GMount* mount) { - std::map<GVolume* , DeviceLauncherIcon* >::iterator it; glib::Object<GVolume> volume(g_mount_get_volume(mount)); - it = self->map_.find(volume); + auto volume_it = map_.find(volume); - if (it != self->map_.end()) - it->second->UpdateVisibility(1); + if (volume_it != map_.end()) + volume_it->second->UpdateVisibility(1); } /* We don't use "mount-removed" signal since it is received after "volume-removed" * signal. You should read also the comment above. */ -void DeviceLauncherSection::OnMountPreUnmount(GVolumeMonitor* monitor, - GMount* mount, - DeviceLauncherSection* self) +void DeviceLauncherSection::OnMountPreUnmount(GVolumeMonitor* monitor, GMount* mount) { - std::map<GVolume* , DeviceLauncherIcon* >::iterator it; glib::Object<GVolume> volume(g_mount_get_volume(mount)); - it = self->map_.find(volume); + auto volume_it = map_.find(volume); - if (it != self->map_.end()) - it->second->UpdateVisibility(0); + if (volume_it != map_.end()) + volume_it->second->UpdateVisibility(0); } } // namespace launcher diff --git a/plugins/unityshell/src/DeviceLauncherSection.h b/plugins/unityshell/src/DeviceLauncherSection.h index 9870f37e4..6ddb7b00e 100644 --- a/plugins/unityshell/src/DeviceLauncherSection.h +++ b/plugins/unityshell/src/DeviceLauncherSection.h @@ -25,6 +25,7 @@ #include <sigc++/sigc++.h> #include <sigc++/signal.h> #include <UnityCore/GLibWrapper.h> +#include <UnityCore/GLibSignal.h> #include "DeviceLauncherIcon.h" @@ -45,31 +46,17 @@ public: sigc::signal<void, AbstractLauncherIcon::Ptr> IconAdded; private: - static bool PopulateEntries(DeviceLauncherSection* self); - - static void OnVolumeAdded(GVolumeMonitor* monitor, - GVolume* volume, - DeviceLauncherSection* self); + void PopulateEntries(); - static void OnVolumeRemoved(GVolumeMonitor* monitor, - GVolume* volume, - DeviceLauncherSection* self); - - static void OnMountAdded(GVolumeMonitor* monitor, - GMount* mount, - DeviceLauncherSection* self); - - static void OnMountPreUnmount(GVolumeMonitor* monitor, - GMount* mount, - DeviceLauncherSection* self); + void OnVolumeAdded(GVolumeMonitor* monitor, GVolume* volume); + void OnVolumeRemoved(GVolumeMonitor* monitor, GVolume* volume); + void OnMountAdded(GVolumeMonitor* monitor, GMount* mount); + void OnMountPreUnmount(GVolumeMonitor* monitor, GMount* mount); private: + glib::SignalManager sig_manager_; glib::Object<GVolumeMonitor> monitor_; std::map<GVolume*, DeviceLauncherIcon*> map_; - gulong on_volume_added_handler_id_; - gulong on_volume_removed_handler_id_; - gulong on_mount_added_handler_id_; - gulong on_mount_pre_unmount_handler_id_; gulong on_device_populate_entry_id_; }; diff --git a/plugins/unityshell/src/LauncherController.cpp b/plugins/unityshell/src/LauncherController.cpp index 2249026b2..a2e0868a2 100644 --- a/plugins/unityshell/src/LauncherController.cpp +++ b/plugins/unityshell/src/LauncherController.cpp @@ -497,7 +497,7 @@ void Controller::Impl::SortAndUpdate() std::stringstream shortcut_string; shortcut_string << (shortcut % 10); icon->SetShortcut(shortcut_string.str()[0]); - shortcut++; + ++shortcut; } // reset shortcut else @@ -607,6 +607,8 @@ void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, st else model_->ReorderBefore(result, other, false); } + + SortAndUpdate(); } void Controller::Impl::OnFavoriteStoreFavoriteRemoved(std::string const& entry) @@ -738,10 +740,11 @@ void Controller::Impl::OnViewOpened(BamfMatcher* matcher, BamfView* view, gpoint return; } - AbstractLauncherIcon::Ptr icon (new BamfLauncherIcon(app)); + AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); + icon->visibility_changed.connect(sigc::mem_fun(self, &Impl::SortAndUpdate)); icon->SetSortPriority(self->sort_priority_++); - self->RegisterIcon(icon); + self->SortAndUpdate(); } AbstractLauncherIcon::Ptr Controller::Impl::CreateFavorite(const char* file_path) @@ -898,7 +901,7 @@ std::vector<char> Controller::GetAllShortcuts() const std::vector<AbstractLauncherIcon::Ptr> Controller::GetAltTabIcons(bool current) const { std::vector<AbstractLauncherIcon::Ptr> results; - + results.push_back(pimpl->desktop_icon_); for (auto icon : *(pimpl->model_)) @@ -911,7 +914,7 @@ std::vector<AbstractLauncherIcon::Ptr> Controller::GetAltTabIcons(bool current) results.push_back(icon); } } - } + } return results; } diff --git a/plugins/unityshell/src/LauncherController.h b/plugins/unityshell/src/LauncherController.h index 8376f0d21..e2dbc7619 100644 --- a/plugins/unityshell/src/LauncherController.h +++ b/plugins/unityshell/src/LauncherController.h @@ -65,10 +65,10 @@ public: void HandleLauncherKeyPress(int when); void HandleLauncherKeyRelease(bool was_tap, int when); - bool HandleLauncherKeyEvent(Display *display, - unsigned int key_sym, - unsigned long key_code, - unsigned long key_state, + bool HandleLauncherKeyEvent(Display *display, + unsigned int key_sym, + unsigned long key_code, + unsigned long key_state, char* key_string); void KeyNavActivate(); diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp index 5ea08d50b..448bd72f5 100644 --- a/plugins/unityshell/src/LauncherIcon.cpp +++ b/plugins/unityshell/src/LauncherIcon.cpp @@ -202,6 +202,7 @@ LauncherIcon::AddProperties(GVariantBuilder* builder) .add("icon_type", _icon_type) .add("tooltip_text", tooltip_text()) .add("sort_priority", _sort_priority) + .add("shortcut", _shortcut) .add("monitors_visibility", g_variant_builder_end(&monitors_builder)) .add("active", GetQuirk(QUIRK_ACTIVE)) .add("visible", GetQuirk(QUIRK_VISIBLE)) @@ -853,6 +854,11 @@ LauncherIcon::SetQuirk(LauncherIcon::Quirk quirk, bool value) UBusServer* ubus = ubus_server_get_default(); ubus_server_send_message(ubus, UBUS_LAUNCHER_ICON_URGENT_CHANGED, g_variant_new_boolean(value)); } + + if (quirk == QUIRK_VISIBLE) + { + visibility_changed.emit(); + } } gboolean diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 5cf27440a..a4e94a797 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -107,10 +107,8 @@ UnityScreen::UnityScreen(CompScreen* screen) , screen(screen) , cScreen(CompositeScreen::get(screen)) , gScreen(GLScreen::get(screen)) + , debugger_(this) , enable_shortcut_overlay_(true) - , wt(nullptr) - , panelWindow(nullptr) - , debugger(nullptr) , needsRelayout(false) , _in_paint(false) , relayoutSourceId(0) @@ -224,20 +222,20 @@ UnityScreen::UnityScreen(CompScreen* screen) nux::NuxInitialize(0); #ifndef USE_GLES - wt = nux::CreateFromForeignWindow(cScreen->output(), - glXGetCurrentContext(), - &UnityScreen::initUnity, - this); + wt.reset(nux::CreateFromForeignWindow(cScreen->output(), + glXGetCurrentContext(), + &UnityScreen::initUnity, + this)); #else - wt = nux::CreateFromForeignWindow(cScreen->output(), - eglGetCurrentContext(), - &UnityScreen::initUnity, - this); + wt.reset(nux::CreateFromForeignWindow(cScreen->output(), + eglGetCurrentContext(), + &UnityScreen::initUnity, + this)); #endif wt->RedrawRequested.connect(sigc::mem_fun(this, &UnityScreen::onRedrawRequested)); - unity_a11y_init(wt); + unity_a11y_init(wt.get()); /* i18n init */ bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); @@ -246,8 +244,6 @@ UnityScreen::UnityScreen(CompScreen* screen) wt->Run(NULL); uScreen = this; - debugger = new unity::debug::DebugDBusInterface(this, this->screen); - _in_paint = false; #ifndef USE_GLES @@ -402,15 +398,7 @@ UnityScreen::~UnityScreen() ::unity::ui::IconRenderer::DestroyTextures(); QuicklistManager::Destroy(); - // We need to delete the controllers before the window thread. - launcher_controller_.reset(); - hud_controller_.reset(); - dash_controller_.reset(); - panel_controller_.reset(); - switcher_controller_.reset(); - shortcut_controller_.reset(); - - delete wt; + reset_glib_logging(); } @@ -2825,17 +2813,17 @@ void UnityScreen::OnDashRealized () void UnityScreen::initLauncher() { Timer timer; - launcher_controller_.reset(new launcher::Controller(screen->dpy())); + launcher_controller_ = std::make_shared<launcher::Controller>(screen->dpy()); AddChild(launcher_controller_.get()); - switcher_controller_.reset(new switcher::Controller()); + switcher_controller_ = std::make_shared<switcher::Controller>(); AddChild(switcher_controller_.get()); LOG_INFO(logger) << "initLauncher-Launcher " << timer.ElapsedSeconds() << "s"; /* Setup panel */ timer.Reset(); - panel_controller_.reset(new panel::Controller()); + panel_controller_ = std::make_shared<panel::Controller>(); AddChild(panel_controller_.get()); panel_controller_->SetMenuShowTimings(optionGetMenusFadein(), optionGetMenusFadeout(), @@ -2845,11 +2833,11 @@ void UnityScreen::initLauncher() LOG_INFO(logger) << "initLauncher-Panel " << timer.ElapsedSeconds() << "s"; /* Setup Places */ - dash_controller_.reset(new dash::Controller()); + dash_controller_ = std::make_shared<dash::Controller>(); dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized)); /* Setup Hud */ - hud_controller_.reset(new hud::Controller()); + hud_controller_ = std::make_shared<hud::Controller>(); auto hide_mode = (unity::launcher::LauncherHideMode) optionGetLauncherHideMode(); hud_controller_->launcher_locked_out = (hide_mode == unity::launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER); hud_controller_->multiple_launchers = (optionGetNumLaunchers() == 0); @@ -2860,7 +2848,7 @@ void UnityScreen::initLauncher() // Setup Shortcut Hint InitHints(); - shortcut_controller_.reset(new shortcut::Controller(hints_)); + shortcut_controller_ = std::make_shared<shortcut::Controller>(hints_); AddChild(shortcut_controller_.get()); AddChild(dash_controller_.get()); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 2275bc0bb..d15d55423 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -240,21 +240,23 @@ private: GeisAdapter geis_adapter_; internal::FavoriteStoreGSettings favorite_store_; + /* The window thread should be the last thing removed, as c++ does it in reverse order */ + std::unique_ptr<nux::WindowThread> wt; + + /* These must stay below the window thread, please keep the order */ launcher::Controller::Ptr launcher_controller_; dash::Controller::Ptr dash_controller_; panel::Controller::Ptr panel_controller_; switcher::Controller::Ptr switcher_controller_; hud::Controller::Ptr hud_controller_; - shortcut::Controller::Ptr shortcut_controller_; + debug::DebugDBusInterface debugger_; + std::list<shortcut::AbstractHint::Ptr> hints_; bool enable_shortcut_overlay_; std::unique_ptr<GestureEngine> gesture_engine_; - nux::WindowThread* wt; - nux::BaseWindow* panelWindow; nux::Geometry lastTooltipArea; - unity::debug::DebugDBusInterface* debugger; bool needsRelayout; bool _in_paint; guint32 relayoutSourceId; @@ -281,7 +283,7 @@ private: nux::Property<nux::Geometry> primary_monitor_; - unity::BGHash _bghash; + BGHash _bghash; #ifdef USE_GLES ::GLFramebufferObject *oldFbo; diff --git a/tests/autopilot/autopilot/emulators/unity/launcher.py b/tests/autopilot/autopilot/emulators/unity/launcher.py index f8a978414..2a11ceda6 100644 --- a/tests/autopilot/autopilot/emulators/unity/launcher.py +++ b/tests/autopilot/autopilot/emulators/unity/launcher.py @@ -301,6 +301,13 @@ class LauncherModel(UnityIntrospectionObject): else: return self.get_children_by_type(SimpleLauncherIcon) + def get_bamf_launcher_icons(self, visible_only=True): + """Get a list of bamf launcher icons in this launcher.""" + if visible_only: + return self.get_children_by_type(BamfLauncherIcon, visible=True) + else: + return self.get_children_by_type(BamfLauncherIcon) + def get_launcher_icons_for_monitor(self, monitor, visible_only=True): """Get a list of launcher icons for provided monitor.""" icons = [] @@ -345,3 +352,7 @@ class LauncherModel(UnityIntrospectionObject): def num_launcher_icons(self): """Get the number of icons in the launcher model.""" return len(self.get_launcher_icons()) + + def num_bamf_launcher_icons(self, visible_only=True): + """Get the number of bamf icons in the launcher model.""" + return len(self.get_bamf_launcher_icons(visible_only)) diff --git a/tests/autopilot/autopilot/tests/test_launcher.py b/tests/autopilot/autopilot/tests/test_launcher.py index 10cf3480e..ed0518f5c 100644 --- a/tests/autopilot/autopilot/tests/test_launcher.py +++ b/tests/autopilot/autopilot/tests/test_launcher.py @@ -499,6 +499,19 @@ class LauncherRevealTests(LauncherTestCase): sleep(5) self.assertThat(self.launcher_instance.is_showing, Equals(False)) + def test_new_icon_has_the_shortcut(self): + """New icons should have an associated shortcut""" + if self.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_by_desktop_id(desktop_file) != None: + self.skip("Calculator icon is already on the launcher.") + + self.start_app('Calculator') + icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + self.assertThat(icon.shortcut, GreaterThan(0)) + class LauncherVisualTests(LauncherTestCase): """Tests for visual aspects of the launcher (icon saturation etc.).""" |
