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...
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:
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" ): "Calculator is already running.")
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_ 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, calc_icon) instance. lock_to_ launcher( calc_icon) all_app( "Calculator" )
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
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_ calculator_ in_launcher_ and_not_ running( self): app("Calculator ") model.get_ icon(desktop_ id=calc. desktop_ file) p(self. launcher_ instance. unlock_ from_launcher, calc_icon) instance. lock_to_ launcher( calc_icon) all_app( "Calculator" ) t(lambda: self.app_ is_running( "Calculator" ), Eventually( Equals( False)) )
calc = self.start_
calc_icon = self.launcher.
self.addCleanu
self.launcher_
self.close_
self.assertTha
return calc_icon
I think you should also move the X11 stuff into a separate function:
def get_startup_ notification_ timestamp( self, bamf_window): Display( ).intern_ atom('_ NET_WM_ USER_TIME' ) Display( ).intern_ atom('CARDINAL' ) x_win.get_ property( atom, atom_type, 0, 1024).value[0]
atom = display.
atom_type = display.
return bamf_window.
Then your test becomes a bit simpler:
def test_launcher_ uses_startup_ notification( self): calculator_ in_launcher_ and_not_ running( ) p(self. close_all_ app, "Calculator") instance. click_launcher_ icon(calc_ icon)
"""Tests that unity uses startup notification protocol."""
calc_icon = self.ensure_
self.addCleanu
self.launcher_
# note - don't re-create bamf - just use it: get_running_ applications_ by_desktop_ file(desktop_ file)[0] get_windows( )[0]
calc_app = self.bamf.
calc_window = calc_app.
self.assertTha t(lambda: self.get_ startup_ notification_ timestamp( calc_window) , Eventually( Equals( calc_icon. startup_ notification_ timestamp) ))
Cheers,