> Hi,
>
> 65 +
>
> This probably doesn't need to be there...
>
> 77 + Time startup_notification_timestamp_;
>
> This is inconsistent with the other member variables (trailing '_' rather than
> leading '_'). Please either follow the existing style, or update the other
> variables as well. Don't leave a file with both styles in place :)
>
> 92 + if self.app_is_running("Calculator"):
> 93 + self.skipTest("Calculator is already running.")
>
> It's fine to kill the calculator if it's running - lots of tests do this
> already. In fact...
>
> 92 + if self.app_is_running("Calculator"):
> 93 + self.skipTest("Calculator is already running.")
> 94 +
> 95 + desktop_file = self.KNOWN_APPS["Calculator"]['desktop-file']
> 96 + calc_icon = self.launcher.model.get_icon(desktop_id=desktop_file)
> 97 +
> 98 + if calc_icon == None:
> 99 + calc = self.start_app("Calculator")
> 100 + desktop_file = calc.desktop_file
> 101 + calc_icon = self.launcher.model.get_icon(desktop_id=desktop_file)
> 102 +
> 103 + self.addCleanup(self.launcher_instance.unlock_from_launcher,
> calc_icon)
> 104 + self.launcher_instance.lock_to_launcher(calc_icon)
> 105 + self.close_all_app("Calculator")
>
> This whole part should go in a utility function, and be called from the test.
> I think you want to refactor it slightly as well. Why not something like this:
>
>
> 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)
> self.addCleanup(self.launcher_instance.unlock_from_launcher,
> calc_icon)
> self.launcher_instance.lock_to_launcher(calc_icon)
> self.close_all_app("Calculator")
> self.assertThat(lambda: self.app_is_running("Calculator"),
> Eventually(Equals(False)))
> return calc_icon
>
> I think you should also move the X11 stuff into a separate function:
>
> def get_startup_notification_timestamp(self, bamf_window):
> atom = display.Display().intern_atom('_NET_WM_USER_TIME')
> atom_type = display.Display().intern_atom('CARDINAL')
> return bamf_window.x_win.get_property(atom, atom_type, 0,
> 1024).value[0]
>
> Then your test becomes a bit simpler:
>
> def test_launcher_uses_startup_notification(self):
> """Tests that unity uses startup notification protocol."""
> calc_icon = self.ensure_calculator_in_launcher_and_not_running()
> self.addCleanup(self.close_all_app, "Calculator")
> self.launcher_instance.click_launcher_icon(calc_icon)
>
> # note - don't re-create bamf - just use it:
> calc_app =
> self.bamf.get_running_applications_by_desktop_file(desktop_file)[0]
> calc_window = calc_app.get_windows()[0]
>
> self.assertThat(lambda:
> self.get_startup_notification_timestamp(calc_window),
> Eventually(Equals(calc_icon.startup_notification_timestamp)))
>
>
> Cheers,
> Hi, notification_ timestamp_ ; is_running( "Calculator" ): "Calculator is already running.") is_running( "Calculator" ): "Calculator is already running.") APPS["Calculato r"]['desktop- file'] model.get_ icon(desktop_ id=desktop_ file) app("Calculator ") model.get_ icon(desktop_ id=desktop_ file) (self.launcher_ instance. unlock_ from_launcher, instance. lock_to_ launcher( calc_icon) all_app( "Calculator" ) calculator_ in_launcher_ and_not_ running( self): app("Calculator ") model.get_ icon(desktop_ id=calc. desktop_ file) (self.launcher_ instance. unlock_ from_launcher, instance. lock_to_ launcher( calc_icon) all_app( "Calculator" ) (lambda: self.app_ is_running( "Calculator" ), Equals( False)) ) notification_ timestamp( self, bamf_window): Display( ).intern_ atom('_ NET_WM_ USER_TIME' ) Display( ).intern_ atom('CARDINAL' ) x_win.get_ property( atom, atom_type, 0, uses_startup_ notification( self): calculator_ in_launcher_ and_not_ running( ) (self.close_ all_app, "Calculator") instance. click_launcher_ icon(calc_ icon) get_running_ applications_ by_desktop_ file(desktop_ file)[0] get_windows( )[0] (lambda: startup_ notification_ timestamp( calc_window) , Equals( calc_icon. startup_ notification_ timestamp) ))
>
> 65 +
>
> This probably doesn't need to be there...
>
> 77 + Time startup_
>
> This is inconsistent with the other member variables (trailing '_' rather than
> leading '_'). Please either follow the existing style, or update the other
> variables as well. Don't leave a file with both styles in place :)
>
> 92 + if self.app_
> 93 + self.skipTest(
>
> It's fine to kill the calculator if it's running - lots of tests do this
> already. In fact...
>
> 92 + if self.app_
> 93 + self.skipTest(
> 94 +
> 95 + desktop_file = self.KNOWN_
> 96 + calc_icon = self.launcher.
> 97 +
> 98 + if calc_icon == None:
> 99 + calc = self.start_
> 100 + desktop_file = calc.desktop_file
> 101 + calc_icon = self.launcher.
> 102 +
> 103 + self.addCleanup
> calc_icon)
> 104 + self.launcher_
> 105 + self.close_
>
> This whole part should go in a utility function, and be called from the test.
> I think you want to refactor it slightly as well. Why not something like this:
>
>
> def ensure_
> calc = self.start_
> calc_icon = self.launcher.
> self.addCleanup
> calc_icon)
> self.launcher_
> self.close_
> self.assertThat
> Eventually(
> return calc_icon
>
> I think you should also move the X11 stuff into a separate function:
>
> def get_startup_
> atom = display.
> atom_type = display.
> return bamf_window.
> 1024).value[0]
>
> Then your test becomes a bit simpler:
>
> def test_launcher_
> """Tests that unity uses startup notification protocol."""
> calc_icon = self.ensure_
> self.addCleanup
> self.launcher_
>
> # note - don't re-create bamf - just use it:
> calc_app =
> self.bamf.
> calc_window = calc_app.
>
> self.assertThat
> self.get_
> Eventually(
>
>
> Cheers,
Done.