4
* This file is part of unity-2d
6
* Copyright 2012 Canonical Ltd.
9
* - Albert Astals Cid <albert.astals@canonical.com>
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.
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.
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/>.
25
require '../run-tests.rb' unless $INIT_COMPLETED
26
require 'xdo/keyboard'
30
############################# Test Suite #############################
31
context "Panel visual verification tests" do
32
pwd = File.expand_path(File.dirname(__FILE__)) + '/'
35
def dash_always_fullscreen
36
out = XDo::XWindow.display_geometry()
39
return width < DASH_MIN_SCREEN_WIDTH && height < DASH_MIN_SCREEN_HEIGHT
42
# Run once at the beginning of this test suite
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'
47
$SUT.execute_shell_command 'killall unity-2d-panel'
48
$SUT.execute_shell_command 'killall unity-2d-panel'
50
$SUT.execute_shell_command 'killall unity-2d-launcher'
51
$SUT.execute_shell_command 'killall unity-2d-launcher'
54
# Run once at the end of this test suite
56
$SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Dash full-screen ' + old_value
59
# Run before each test case begins
61
# Execute the application
62
@app = $SUT.run( :name => UNITY_2D_PANEL,
63
:arguments => "-testability",
66
@launcher = $SUT.run( :name => UNITY_2D_SHELL,
67
:arguments => "-testability",
72
# Run after each test case completes
74
$SUT.execute_shell_command 'pkill -nf unity-2d-panel'
75
$SUT.execute_shell_command 'pkill -nf unity-2d-launcher'
78
#####################################################################################
81
test "Visually compare dash buttons with reference" do
82
XDo::Mouse.move(100, 100, 0, true)
83
XDo::Keyboard.simulate('{SUPER}')
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
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
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
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
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
111
verify_true( TIMEOUT, 'maximize button not matching reference image' ) {
112
maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button.png') != nil
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
121
verify_true( TIMEOUT, 'maximize button pressed not matching reference image' ) {
122
maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_pressed.png') != nil
126
minimizeButton.move_mouse() # move mouse away
128
verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
129
maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen.png') != nil
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
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
144
closeButton.move_mouse()
146
verify_true( TIMEOUT, 'close button pressed not matching reference image' ) {
147
closeButton.find_on_screen(pwd + 'verification/dash_close_button_pressed.png') != nil