~unity-2d-team/unity-2d/shortcut-hint-overlay

« back to all changes in this revision

Viewing changes to tests/panel/visual_verification.rb

  • Committer: Tiago Salem Herrmann
  • Date: 2012-03-19 15:28:41 UTC
  • mfrom: (771.40.182 unity-2d)
  • Revision ID: tiago.herrmann@canonical.com-20120319152841-2hfflo67muks7gca
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env ruby1.8
2
 
=begin
3
 
/*
4
 
 * This file is part of unity-2d
5
 
 *
6
 
 * Copyright 2012 Canonical Ltd.
7
 
 *
8
 
 * Authors:
9
 
 * - Albert Astals Cid <albert.astals@canonical.com>
10
 
 *
11
 
 * This program is free software; you can redistribute it and/or modify
12
 
 * it under the terms of the GNU General Public License as published by
13
 
 * the Free Software Foundation; version 3.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 
 */
23
 
=end
24
 
 
25
 
require '../run-tests.rb' unless $INIT_COMPLETED
26
 
require 'xdo/keyboard'
27
 
require 'xdo/mouse'
28
 
require 'xdo/xwindow'
29
 
 
30
 
############################# Test Suite #############################
31
 
context "Panel visual verification tests" do
32
 
  pwd = File.expand_path(File.dirname(__FILE__)) + '/'
33
 
  old_value = ""
34
 
 
35
 
  def dash_always_fullscreen
36
 
    out = XDo::XWindow.display_geometry()
37
 
    width = out[0]
38
 
    height = out[1]
39
 
    return width < DASH_MIN_SCREEN_WIDTH && height < DASH_MIN_SCREEN_HEIGHT
40
 
  end
41
 
 
42
 
  # Run once at the beginning of this test suite
43
 
  startup do
44
 
    old_value = $SUT.execute_shell_command 'gsettings get com.canonical.Unity2d.Dash full-screen'
45
 
    $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Dash full-screen false'
46
 
 
47
 
    $SUT.execute_shell_command 'killall unity-2d-panel'
48
 
    $SUT.execute_shell_command 'killall unity-2d-panel'
49
 
 
50
 
    $SUT.execute_shell_command 'killall unity-2d-launcher'
51
 
    $SUT.execute_shell_command 'killall unity-2d-launcher'
52
 
  end
53
 
 
54
 
  # Run once at the end of this test suite
55
 
  shutdown do
56
 
      $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Dash full-screen ' + old_value
57
 
  end
58
 
 
59
 
  # Run before each test case begins
60
 
  setup do
61
 
    # Execute the application 
62
 
    @app = $SUT.run( :name => UNITY_2D_PANEL,
63
 
                     :arguments => "-testability",
64
 
                     :sleeptime => 2 )
65
 
 
66
 
    @launcher = $SUT.run( :name => UNITY_2D_SHELL,
67
 
                       :arguments => "-testability",
68
 
                       :sleeptime => 2 )
69
 
 
70
 
  end
71
 
 
72
 
  # Run after each test case completes
73
 
  teardown do
74
 
    $SUT.execute_shell_command 'pkill -nf unity-2d-panel'
75
 
    $SUT.execute_shell_command 'pkill -nf unity-2d-launcher'
76
 
  end
77
 
 
78
 
  #####################################################################################
79
 
  # Test cases
80
 
 
81
 
  test "Visually compare dash buttons with reference" do
82
 
    XDo::Mouse.move(100, 100, 0, true)
83
 
    XDo::Keyboard.simulate('{SUPER}')
84
 
 
85
 
    closeButton = @app.AppNameApplet().QAbstractButton( :name => 'AppNameApplet::CloseButton' )
86
 
    verify_true( TIMEOUT, 'close button not matching reference image' ) {
87
 
      closeButton.find_on_screen(pwd + 'verification/dash_close_button.png') != nil
88
 
    }
89
 
 
90
 
    closeButton.move_mouse
91
 
    verify_true( TIMEOUT, 'close button not matching reference image' ) {
92
 
      closeButton.find_on_screen(pwd + 'verification/dash_close_button_over.png') != nil
93
 
    }
94
 
 
95
 
    minimizeButton = @app.AppNameApplet().QAbstractButton( :name => 'AppNameApplet::MinimizeButton' )
96
 
    verify_true( TIMEOUT, 'minimize button not matching reference image' ) {
97
 
      minimizeButton.find_on_screen(pwd + 'verification/dash_minimize_button.png') != nil
98
 
    }
99
 
 
100
 
    maximizeButton = @app.AppNameApplet().QAbstractButton( :name => 'AppNameApplet::MaximizeButton' )
101
 
    if dash_always_fullscreen
102
 
      verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
103
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen.png') != nil
104
 
      }
105
 
 
106
 
      maximizeButton.move_mouse
107
 
      verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
108
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen_over.png') != nil
109
 
      }
110
 
    else
111
 
      verify_true( TIMEOUT, 'maximize button not matching reference image' ) {
112
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button.png') != nil
113
 
      }
114
 
 
115
 
      maximizeButton.move_mouse()
116
 
      verify_true( TIMEOUT, 'maximize button not matching reference image' ) {
117
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_over.png') != nil
118
 
      }
119
 
 
120
 
      XDo::Mouse.down()
121
 
      verify_true( TIMEOUT, 'maximize button pressed not matching reference image' ) {
122
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_pressed.png') != nil
123
 
      }
124
 
      XDo::Mouse.up()
125
 
 
126
 
      minimizeButton.move_mouse() # move mouse away
127
 
 
128
 
      verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
129
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen.png') != nil
130
 
      }
131
 
 
132
 
      maximizeButton.move_mouse()
133
 
      verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
134
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen_over.png') != nil
135
 
      }
136
 
 
137
 
      XDo::Mouse.down()
138
 
      verify_true( TIMEOUT, 'maximize button fullscreen pressed not matching reference image' ) {
139
 
        maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen_pressed.png') != nil
140
 
      }
141
 
      XDo::Mouse.up()
142
 
    end
143
 
 
144
 
    closeButton.move_mouse()
145
 
    XDo::Mouse.down()
146
 
    verify_true( TIMEOUT, 'close button pressed not matching reference image' ) {
147
 
      closeButton.find_on_screen(pwd + 'verification/dash_close_button_pressed.png') != nil
148
 
    }
149
 
    XDo::Mouse.up()
150
 
  end
151
 
end