Code review comment for lp:~3v1n0/unity/avoid-duplicate-icons

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

Please try and replace the call() lines with this:

call("kill `pidof %s`" % (app['process-name']), shell=True)

Don't use pkill -f - it's dangerous. Once making these changes, please ensure that all the tests still pass.

130 + self.start_app("Calculator")
131 + self.start_app("System Settings")
132 + os.spawnlp(os.P_NOWAIT, "xterm", "xterm", "-title", "Autopilot XTerm", "-e", "sh")
133 + self.addCleanup(call, ["killall", "xterm"])
134 +
135 + # FIXME bamf emulator should wait until a window is open
136 + sleep(1)
137 + [xterm_win] = [w for w in self.bamf.get_open_windows() if w.name == "Autopilot XTerm"]
138 + self.assertTrue(xterm_win.is_focused)

Please put all this in a method called "start_test_apps or something similar, then call it from your test.

154 + same_desktop = [i for i in bamf_icons if i.desktop_file == icon.desktop_file]
155 + self.assertThat(len(same_desktop), Equals(1))

Can you use 'get_icon_by_desktop_file' on the launcher model, to avoid this?

157 + same_appid = [i for i in bamf_icons if i.application_id == icon.application_id]
158 + self.assertThat(len(same_appid), Equals(1))

Similar thing here... we should probable add something to the launcher model like this:

def get_icon_by_filter(self, **kwargs):
        """Gets a launcher icon that matches the filter specified.

        Returns None if there is no such launcher icon.
        """
        icons = self.get_children_by_type(SimpleLauncherIcon, **kwargs)
        if len(icons):
            return icons[0]

        return None

review: Needs Fixing

« Back to merge proposal