summaryrefslogtreecommitdiff
diff options
authorBrandon Schaefer <brandontschaefer@gmail.com>2012-07-12 16:36:38 -0700
committerBrandon Schaefer <brandontschaefer@gmail.com>2012-07-12 16:36:38 -0700
commitcee9034868840cc8149ea65061ce74a1b7822163 (patch)
tree4b7cf1a7182c3a0c450a9eab3b68fc0c2ed7aceb
parent117acf75ae2fa5e9be1abc22482cf45017a32fbe (diff)
parentea12e8f73a2e3dbd00b3739699cb70b4292f83cf (diff)
* Merged trunk, and fixed ap test
(bzr r2497.1.2)
-rw-r--r--launcher/BamfLauncherIcon.cpp3
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/autopilot/unity/emulators/hud.py5
-rw-r--r--tests/autopilot/unity/tests/__init__.py19
-rw-r--r--tests/autopilot/unity/tests/launcher/test_icon_behavior.py3
-rw-r--r--tests/autopilot/unity/tests/test_hud.py4
-rw-r--r--tests/autopilot/unity/tests/test_panel.py102
-rw-r--r--tests/autopilot/unity/tests/test_showdesktop.py9
-rw-r--r--tests/data/no-icon.desktop7
-rw-r--r--tests/test_bamflaunchericon.cpp44
-rw-r--r--unity-shared/PluginAdapterStandalone.cpp48
11 files changed, 160 insertions, 86 deletions
diff --git a/launcher/BamfLauncherIcon.cpp b/launcher/BamfLauncherIcon.cpp
index 26ba33791..699a6b0f1 100644
--- a/launcher/BamfLauncherIcon.cpp
+++ b/launcher/BamfLauncherIcon.cpp
@@ -51,6 +51,7 @@ nux::logging::Logger logger("unity.launcher");
const std::string WINDOW_MOVE_TIMEOUT = "bamf-window-move";
const std::string ICON_REMOVE_TIMEOUT = "bamf-icon-remove";
//const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over";
+ const std::string DEFAULT_ICON = "application-default-icon";
}
NUX_IMPLEMENT_OBJECT_TYPE(BamfLauncherIcon);
@@ -69,7 +70,7 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app)
glib::String icon(bamf_view_get_icon(bamf_view));
tooltip_text = BamfName();
- icon_name = icon.Str();
+ icon_name = (icon ? icon.Str() : DEFAULT_ICON);
SetIconType(TYPE_APPLICATION);
if (IsSticky())
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0cea996e3..347f99312 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -11,6 +11,8 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/update-manager.desktop
${CMAKE_BINARY_DIR}/tests/data/update-manager.desktop)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/bzr-handle-patch.desktop
${CMAKE_BINARY_DIR}/tests/data/bzr-handle-patch.desktop)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/no-icon.desktop
+ ${CMAKE_BINARY_DIR}/tests/data/no-icon.desktop)
#
# Unit tests
#
diff --git a/tests/autopilot/unity/emulators/hud.py b/tests/autopilot/unity/emulators/hud.py
index c0e841ead..500a607a8 100644
--- a/tests/autopilot/unity/emulators/hud.py
+++ b/tests/autopilot/unity/emulators/hud.py
@@ -32,6 +32,11 @@ class Hud(KeybindingsHelper):
def ensure_hidden(self):
"""Hides the hud if it's not already hidden."""
if self.visible:
+ if self.search_string:
+ # need this to clear the search string, and then another to
+ # close the hud.
+ self.keyboard.press_and_release("Escape")
+ self.search_string.wait_for("")
self.keyboard.press_and_release("Escape")
self.visible.wait_for(False)
diff --git a/tests/autopilot/unity/tests/__init__.py b/tests/autopilot/unity/tests/__init__.py
index a241a0a63..90b7c10ae 100644
--- a/tests/autopilot/unity/tests/__init__.py
+++ b/tests/autopilot/unity/tests/__init__.py
@@ -65,37 +65,37 @@ class UnityTestCase(AutopilotTestCase):
log.info("Checking system state for badly behaving test...")
# Have we switched workspace?
- if self.workspace.current_workspace != self._initial_workspace_num:
+ if not self.well_behaved(self.workspace, current_workspace=self._initial_workspace_num):
well_behaved = False
reasons.append("The test changed the active workspace from %d to %d." \
% (self._initial_workspace_num, self.workspace.current_workspace))
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 self.dash.visible:
+ if not self.well_behaved(self.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()
# ... or the hud?
- if self.hud.visible:
+ if not self.well_behaved(self.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 self.window_manager.showdesktop_active:
+ if not self.well_behaved(self.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...")
self.window_manager.leave_show_desktop()
for launcher in self.launcher.get_launchers():
- if launcher.in_keynav_mode:
+ if not self.well_behaved(launcher, in_keynav_mode=False):
well_behaved = False
reasons.append("The test left the launcher keynav mode enabled.")
log.warning("Test left the launcher in keynav mode, exiting it...")
launcher.key_nav_cancel()
- if launcher.in_switcher_mode:
+ if not self.well_behaved(launcher, in_switcher_mode=False):
well_behaved = False
reasons.append("The test left the launcher in switcher mode.")
log.warning("Test left the launcher in switcher mode, exiting it...")
@@ -106,6 +106,13 @@ class UnityTestCase(AutopilotTestCase):
else:
log.info("Test was well behaved.")
+ def well_behaved(self, object, **kwargs):
+ try:
+ self.assertProperty(object, **kwargs)
+ except AssertionError:
+ return False
+ return True
+
@property
def dash(self):
if not getattr(self, '__dash', None):
diff --git a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py
index d4aaacedc..bd6eab38c 100644
--- a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py
+++ b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py
@@ -127,6 +127,7 @@ class LauncherIconsTests(LauncherTestCase):
calc_icon = self.launcher.model.get_icon(desktop_id=calc_app.desktop_file)
self.launcher_instance.click_launcher_icon(calc_icon)
+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
@@ -166,7 +167,7 @@ class LauncherDragIconsBehavior(LauncherTestCase):
# the old fashioned way.
refresh_fn = lambda: self.launcher.model.get_children_by_type(
BamfLauncherIcon, desktop_id="gcalctool.desktop")
- self.assertThat(refresh_fn, Eventually(Equals(None)))
+ self.assertThat(refresh_fn, Eventually(Equals([])))
def test_can_drag_icon_below_bfb(self):
"""Application icons must be draggable to below the BFB."""
diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py
index 9411184a0..859b018a0 100644
--- a/tests/autopilot/unity/tests/test_hud.py
+++ b/tests/autopilot/unity/tests/test_hud.py
@@ -358,9 +358,9 @@ class HudLockedLauncherInteractionsTests(HudTestsBase):
for icon in self.launcher.model.get_launcher_icons_for_monitor(self.hud_monitor):
if isinstance(icon, HudLauncherIcon):
- self.assertFalse(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(False)))
else:
- self.assertTrue(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(True)))
def test_hud_launcher_icon_click_hides_hud(self):
"""Clicking the Hud Icon should hide the HUD"""
diff --git a/tests/autopilot/unity/tests/test_panel.py b/tests/autopilot/unity/tests/test_panel.py
index abbb77641..d98580909 100644
--- a/tests/autopilot/unity/tests/test_panel.py
+++ b/tests/autopilot/unity/tests/test_panel.py
@@ -54,9 +54,8 @@ class PanelTestsBase(UnityTestCase):
"""
self.close_all_app(app_name)
- app = self.start_app(app_name, locale="C")
-
- [app_win] = app.get_windows()
+ app_win = self.start_app_window(app_name, locale="C")
+ app = app_win.application
app_win.set_focus()
self.assertTrue(app.is_active)
@@ -113,7 +112,7 @@ class PanelTestsBase(UnityTestCase):
self.addCleanup(self.keyboard.press_and_release, "Escape")
self.assertThat(indicator.active, Eventually(Equals(True)))
- def assert_win_buttons_in_overlay_mode(self, overlay_mode):
+ def assertWinButtonsInOverlayMode(self, overlay_mode):
"""Assert that there are three panel window buttons and all of them are
in the specified overlay mode.
@@ -126,7 +125,7 @@ class PanelTestsBase(UnityTestCase):
for button in buttons:
self.assertThat(button.overlay_mode, Eventually(Equals(overlay_mode)))
- def assert_no_window_open_with_xid(self, x_id):
+ def assertNoWindowOpenWithXid(self, x_id):
"""Assert that Bamf doesn't know of any open windows with the given xid."""
# We can't check text_win.closed since we've just destroyed the window.
# Instead we make sure no window with it's x_id exists.
@@ -225,7 +224,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_window_buttons_dont_show_on_empty_desktop(self):
"""Tests that the window buttons are not shown on clean desktop."""
- # THis initially used Show Desktop mode, but it's very buggy from within
+ # This initially used Show Desktop mode, but it's very buggy from within
# autopilot. We assume that workspace 2 is empty (which is safe for the
# jenkins runs at least.)
initial_workspace = self.workspace.current_workspace
@@ -272,7 +271,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.panel.move_mouse_over_window_buttons()
self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
- self.assert_win_buttons_in_overlay_mode(False)
+ self.assertWinButtonsInOverlayMode(False)
def test_window_buttons_show_with_dash(self):
"""Window buttons must be shown when the dash is open."""
@@ -280,7 +279,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.addCleanup(self.dash.ensure_hidden)
self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
- self.assert_win_buttons_in_overlay_mode(True)
+ self.assertWinButtonsInOverlayMode(True)
def test_window_buttons_show_with_hud(self):
"""Window buttons must be shown when the HUD is open."""
@@ -288,7 +287,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.addCleanup(self.hud.ensure_hidden)
self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
- self.assert_win_buttons_in_overlay_mode(True)
+ self.assertWinButtonsInOverlayMode(True)
def test_window_buttons_update_visual_state(self):
"""Window button must update its state in response to mouse events."""
@@ -310,19 +309,9 @@ class PanelWindowButtonsTests(PanelTestsBase):
their area.
"""
self.hud.ensure_visible()
- button = self.panel.window_buttons.close
-
- # FIXME: THere's a bug in unity that prevents us from doing:
- # self.addCleanup(self.hud.ensure_hidden)
- # SO we do this instead. The bug is:
- #
- # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
- #
- # Once that's fixed the next two lines can be removed, and the one above
- # added instead.
- self.addCleanup(self.assertThat, self.hud.visible, Eventually(Equals(False)))
- self.addCleanup(button.mouse_click)
+ self.addCleanup(self.hud.ensure_hidden)
+ button = self.panel.window_buttons.close
button.mouse_move_to()
self.mouse.press()
self.assertThat(button.visual_state, Eventually(Equals("pressed")))
@@ -340,7 +329,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
win_xid = text_win.x_id
self.panel.window_buttons.close.mouse_click()
- self.assert_no_window_open_with_xid(win_xid)
+ self.assertNoWindowOpenWithXid(win_xid)
def test_window_buttons_close_follows_fitts_law(self):
"""Tests that the 'Close' button is activated when clicking at 0,0.
@@ -357,7 +346,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.mouse.move(screen_x, screen_y)
self.mouse.click()
- self.assert_no_window_open_with_xid(win_xid)
+ self.assertNoWindowOpenWithXid(win_xid)
def test_window_buttons_minimize_button_works_for_window(self):
"""Tests that the window button 'Minimize' actually minimizes a window."""
@@ -367,7 +356,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.panel.window_buttons.minimize.mouse_click()
- self.assertThat(lambda: text_win.is_hidden, Eventually(Equals(True)))
+ self.assertProperty(text_win, is_hidden=True)
def test_window_buttons_minimize_follows_fitts_law(self):
"""Tests that the 'Minimize' button is conform to Fitts's Law.
@@ -385,7 +374,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.mouse.move(target_x, target_y)
self.mouse.click()
- self.assertThat(lambda: text_win.is_hidden, Eventually(Equals(True)))
+ self.assertProperty(text_win, is_hidden=True)
def test_window_buttons_unmaximize_button_works_for_window(self):
"""Tests that the window button 'Unmaximize' actually unmaximizes a window."""
@@ -415,7 +404,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
sleep(1)
self.mouse.click()
- self.assertThat(lambda: text_win.is_maximized, Eventually(Equals(False)))
+ self.assertProperty(text_win, is_maximized=False)
def test_window_buttons_close_button_works_for_hud(self):
"""Tests that the window 'Close' actually closes the HUD."""
@@ -435,13 +424,8 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_minimize_button_does_nothing_for_hud(self):
"""Minimize button must not affect the Hud."""
self.hud.ensure_visible()
- # FIXME: When this bug is fixed:
- #
- # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
- #
- # We can replace the following line with:
- # self.addCleanup(self.hud.ensure_hidden)
- self.addCleanup(self.panel.window_buttons.close.mouse_click)
+ self.addCleanup(self.hud.ensure_hidden)
+
self.panel.window_buttons.minimize.mouse_click()
self.assertThat(self.hud.visible, Eventually(Equals(True)))
@@ -456,13 +440,8 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_maximize_button_does_nothing_for_hud(self):
"""Maximize button must not affect the Hud."""
self.hud.ensure_visible()
- # FIXME: When this bug is fixed:
- #
- # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
- #
- # We can replace the following line with:
- # self.addCleanup(self.hud.ensure_hidden)
- self.addCleanup(self.panel.window_buttons.close.mouse_click)
+ self.addCleanup(self.hud.ensure_hidden)
+
self.panel.window_buttons.maximize.mouse_click()
self.assertThat(self.hud.visible, Eventually(Equals(True)))
@@ -475,13 +454,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
"""
inital_form_factor = self.dash.view.form_factor
self.hud.ensure_visible()
- # FIXME: When this bug is fixed:
- #
- # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
- #
- # We can replace the following line with:
- # self.addCleanup(self.hud.ensure_hidden)
- self.addCleanup(self.panel.window_buttons.close.mouse_click)
+ self.addCleanup(self.hud.ensure_hidden)
self.panel.window_buttons.maximize.mouse_click()
# long sleep here to make sure that any change that might happen will
@@ -595,7 +568,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.move_window_to_panel_monitor(target_win, restore_position=False)
self.keybinding("window/maximize")
- self.assertThat(lambda: target_win.is_maximized, Eventually(Equals(True)))
+ self.assertProperty(target_win, is_maximized=True)
self.assertThat(self.panel.window_buttons.close.enabled, Eventually(Equals(True)))
self.assertThat(self.panel.window_buttons.minimize.enabled, Eventually(Equals(False)))
@@ -906,10 +879,17 @@ class PanelIndicatorEntryTests(PanelTestsBase):
scenarios = _make_monitor_scenarios()
- def test_menu_opens_on_click(self):
- """Tests that clicking on a menu entry, opens a menu."""
+ def open_app_and_get_menu_entry(self):
+ """Open the test app and wait for the menu entry to appear."""
self.open_new_application_window("Calculator")
+ refresh_fn = lambda: len(self.panel.menus.get_entries())
+ self.assertThat(refresh_fn, Eventually(GreaterThan(0)))
menu_entry = self.panel.menus.get_entries()[0]
+ return menu_entry
+
+ def test_menu_opens_on_click(self):
+ """Tests that clicking on a menu entry, opens a menu."""
+ menu_entry = self.open_app_and_get_menu_entry()
self.mouse_open_indicator(menu_entry)
self.assertThat(menu_entry.active, Eventually(Equals(True)))
@@ -918,8 +898,7 @@ class PanelIndicatorEntryTests(PanelTestsBase):
def test_menu_opens_closes_on_click(self):
"""Clicking on an open menu entru must close it again."""
- self.open_new_application_window("Calculator")
- menu_entry = self.panel.menus.get_entries()[0]
+ menu_entry = self.open_app_and_get_menu_entry()
self.mouse_open_indicator(menu_entry)
# This assert is for timing purposes only:
@@ -932,8 +911,7 @@ class PanelIndicatorEntryTests(PanelTestsBase):
def test_menu_closes_on_click_outside(self):
"""Clicking outside an open menu must close it."""
- self.open_new_application_window("Calculator")
- menu_entry = self.panel.menus.get_entries()[0]
+ menu_entry = self.open_app_and_get_menu_entry()
self.mouse_open_indicator(menu_entry)
# This assert is for timing purposes only:
@@ -973,7 +951,7 @@ class PanelKeyNavigationTests(PanelTestsBase):
self.assertThat(open_indicator.entry_id, Eventually(Equals(expected_indicator.entry_id)))
self.keybinding("panel/open_first_menu")
- self.assertThat(self.panel.get_active_indicator(), Eventually(Equals(None)))
+ self.assertThat(self.panel.get_active_indicator, Eventually(Equals(None)))
def test_panel_menu_accelerators_work(self):
"""Pressing a valid menu accelerator must open the correct menu item."""
@@ -1050,33 +1028,33 @@ class PanelGrabAreaTests(PanelTestsBase):
self.panel.move_mouse_below_the_panel()
self.mouse.release()
- self.assertThat(lambda: text_win.is_maximized, Eventually(Equals(False)))
+ self.assertProperty(text_win, is_maximized=False)
def test_focus_the_maximized_window_works(self):
"""Clicking on the grab area must put a maximized window in focus."""
text_win = self.open_new_application_window("Text Editor", maximized=True)
calc_win = self.open_new_application_window("Calculator")
- self.assertThat(lambda: text_win.is_focused, Eventually(Equals(False)))
- self.assertThat(lambda: calc_win.is_focused, Eventually(Equals(True)))
+ self.assertProperty(text_win, is_focused=False)
+ self.assertProperty(calc_win, is_focused=True)
self.move_mouse_over_grab_area()
self.mouse.click()
- self.assertThat(lambda: text_win.is_focused, Eventually(Equals(True)))
+ self.assertProperty(text_win, is_focused=True)
def test_lower_the_maximized_window_works(self):
"""Middle-clicking on the panel grab area must lower a maximized window."""
calc_win = self.open_new_application_window("Calculator")
text_win = self.open_new_application_window("Text Editor", maximized=True)
- self.assertThat(lambda: text_win.is_focused, Eventually(Equals(True)))
- self.assertThat(lambda: calc_win.is_focused, Eventually(Equals(False)))
+ self.assertProperty(text_win, is_focused=True)
+ self.assertProperty(calc_win, is_focused=False)
self.move_mouse_over_grab_area()
self.mouse.click(2)
- self.assertThat(lambda: calc_win.is_focused, Eventually(Equals(True)))
+ self.assertProperty(calc_win, is_focused=True)
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."""
diff --git a/tests/autopilot/unity/tests/test_showdesktop.py b/tests/autopilot/unity/tests/test_showdesktop.py
index e2f87faed..6efc9d972 100644
--- a/tests/autopilot/unity/tests/test_showdesktop.py
+++ b/tests/autopilot/unity/tests/test_showdesktop.py
@@ -8,11 +8,8 @@
from __future__ import absolute_import
-from autopilot.matchers import Eventually
-from testtools.matchers import NotEquals
from time import sleep
-from unity.emulators.icons import DesktopLauncherIcon
from unity.tests import UnityTestCase
@@ -65,13 +62,13 @@ class ShowDesktopTests(UnityTestCase):
def test_unhide_single_app(self):
"""Un-hide a single app from launcher after hiding all apps."""
- test_windows = self.launch_test_apps()
+ 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)
- for win in test_windows:
+ for win in (charmap, calc):
self.assertProperty(win, is_valid=True)
self.assertProperty(win, is_hidden=True)
@@ -88,7 +85,7 @@ class ShowDesktopTests(UnityTestCase):
# hide desktop - now all windows should be visible:
self.window_manager.leave_show_desktop()
- for win in test_windows:
+ for win in (charmap, calc):
self.assertProperty(win, is_hidden=False)
def test_showdesktop_switcher(self):
diff --git a/tests/data/no-icon.desktop b/tests/data/no-icon.desktop
new file mode 100644
index 000000000..4f2902fe2
--- /dev/null
+++ b/tests/data/no-icon.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=Default
+Comment=Interactive viewer for a Default icon!
+Exec=gedit
+Terminal=false
+Type=Application
+Categories=GTK;Science;Graphics;
diff --git a/tests/test_bamflaunchericon.cpp b/tests/test_bamflaunchericon.cpp
index 9719e9a5f..f84312f5a 100644
--- a/tests/test_bamflaunchericon.cpp
+++ b/tests/test_bamflaunchericon.cpp
@@ -15,6 +15,7 @@
* <http://www.gnu.org/licenses/>
*
* Authored by: Andrea Azzarone <azzarone@gmail.com>
+ * Brandon Schaefer <brandon.schaefer@canonical.com>
*/
#include <config.h>
@@ -23,6 +24,11 @@
#include <UnityCore/GLibWrapper.h>
#include "BamfLauncherIcon.h"
+
+#include "unity-shared/PluginAdapter.h"
+#include <gio/gdesktopappinfo.h>
+#include <unistd.h>
+
using namespace unity;
namespace
@@ -62,4 +68,42 @@ TEST_F(TestBamfLauncherIcon, TestCustomBackgroundColor)
EXPECT_EQ(color.alpha, 0xff / 255.0f);
}
+TEST_F(TestBamfLauncherIcon, TestDefaultIcon)
+{
+ glib::Error error;
+ BamfApplication* app;
+ nux::ObjectPtr<launcher::BamfLauncherIcon> default_icon;
+
+ glib::Object<GDesktopAppInfo> desktopInfo(g_desktop_app_info_new_from_filename(BUILDDIR"/tests/data/no-icon.desktop"));
+ auto appInfo = glib::object_cast<GAppInfo>(desktopInfo);
+
+ g_app_info_launch(appInfo, nullptr, nullptr, &error);
+
+ if (error)
+ g_warning("%s\n", error.Message().c_str());
+ EXPECT_FALSE(error);
+
+ for (int i = 0; i < 5 && !bamf_matcher_application_is_running(bamf_matcher, BUILDDIR"/tests/data/no-icon.desktop"); i++)
+ sleep(1);
+ EXPECT_TRUE(bamf_matcher_application_is_running(bamf_matcher, BUILDDIR"/tests/data/no-icon.desktop"));
+
+ app = bamf_matcher_get_active_application(bamf_matcher);
+ default_icon = new launcher::BamfLauncherIcon(app);
+
+ GList* children, *l;
+ children = bamf_view_get_children(BAMF_VIEW(app));
+
+ for (l = children; l; l = l->next)
+ {
+ if (!BAMF_IS_WINDOW(l->data))
+ continue;
+
+ Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data));
+ PluginAdapter::Default()->Close(xid);
+ }
+ g_list_free(children);
+
+ EXPECT_EQ(default_icon->icon_name.Get(), "application-default-icon");
+}
+
}
diff --git a/unity-shared/PluginAdapterStandalone.cpp b/unity-shared/PluginAdapterStandalone.cpp
index 5708bfbc4..672d84ac5 100644
--- a/unity-shared/PluginAdapterStandalone.cpp
+++ b/unity-shared/PluginAdapterStandalone.cpp
@@ -124,7 +124,7 @@ MultiActionList::TerminateAll(CompOption::Vector& extraArgs)
{
}
-unsigned long long
+unsigned long long
PluginAdapter::GetWindowActiveNumber (guint32 xid)
{
return 0;
@@ -264,6 +264,38 @@ PluginAdapter::Minimize(guint32 xid)
void
PluginAdapter::Close(guint32 xid)
{
+ GdkDisplay* gdkdisplay;
+ GdkScreen* screen;
+ Display* xdisplay;
+ Atom net_close_win;
+ Window xroot;
+ XEvent ev;
+
+ gdkdisplay = gdk_display_get_default();
+ xdisplay = GDK_DISPLAY_XDISPLAY(gdkdisplay);
+ screen = gdk_display_get_default_screen (gdkdisplay);
+ xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));
+
+ net_close_win = XInternAtom (xdisplay, "_NET_CLOSE_WINDOW", 0);
+
+ ev.xclient.type = ClientMessage;
+ ev.xclient.display = xdisplay;
+
+ ev.xclient.serial = 0;
+ ev.xclient.send_event = TRUE;
+
+ ev.xclient.window = xid;
+ ev.xclient.message_type = net_close_win;
+ ev.xclient.format = 32;
+
+ ev.xclient.data.l[0] = CurrentTime;
+ ev.xclient.data.l[1] = 1; //application
+
+ XSendEvent (xdisplay, xroot, FALSE,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &ev);
+
+ XSync (xdisplay, FALSE);
}
void
@@ -281,18 +313,18 @@ PluginAdapter::Lower(guint32 xid)
{
}
-void
+void
PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility focus_visibility, int monitor, bool only_top_win)
{
}
-bool
+bool
PluginAdapter::ScaleWindowGroup(std::vector<Window> windows, int state, bool force)
{
return false;
}
-void
+void
PluginAdapter::SetWindowIconGeometry(Window window, nux::Geometry const& geo)
{
}
@@ -332,14 +364,14 @@ PluginAdapter::GetWindowSavedGeometry(guint32 xid) const
return geo;
}
-nux::Geometry
+nux::Geometry
PluginAdapter::GetScreenGeometry() const
{
nux::Geometry geo(0, 0, 1, 1);
- return geo;
+ return geo;
}
-nux::Geometry
+nux::Geometry
PluginAdapter::GetWorkAreaGeometry(guint32 xid) const
{
nux::Geometry geo(0, 0, 1, 1);
@@ -352,7 +384,7 @@ PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow*
return false;
}
-void
+void
PluginAdapter::CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any)
{
}