~sil2100/unity-2d/precise-security

« back to all changes in this revision

Viewing changes to tests/misc/lib/xdo/test/test_xwindow.rb

  • Committer: Aurelien Gateau
  • Date: 2010-11-10 08:57:29 UTC
  • mto: This revision was merged to the branch mainline in revision 284.
  • Revision ID: aurelien.gateau@canonical.com-20101110085729-fl1ye7impkqhm0w6
Added a section about const correct-ness

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env ruby
2
 
#Encoding: UTF-8
3
 
 
4
 
require "test/unit"
5
 
require File.join(File.dirname(__FILE__), '../xwindow')
6
 
require File.join(File.dirname(__FILE__), '../keyboard')
7
 
 
8
 
class WindowTest < Test::Unit::TestCase
9
 
  
10
 
  attr_accessor :xwindow
11
 
  
12
 
  #The command used to create new windows. 
13
 
  #The program MUST NOT start maximized. xdotool has no possibility of 
14
 
  #acting on maximized windows.
15
 
  NEW_WINDOW_NAME = "Home"
16
 
  NEW_WINDOW_CMD = "nautilus"
17
 
  
18
 
  @@xwin = nil
19
 
  
20
 
  def setup
21
 
    @editor_pipe = IO.popen(NEW_WINDOW_CMD, 'r')
22
 
    XDo::XWindow.wait_for_window(Regexp.new(Regexp.escape(NEW_WINDOW_NAME)))
23
 
    @@xwin = XDo::XWindow.from_title(Regexp.new(Regexp.escape(NEW_WINDOW_NAME)))
24
 
  end
25
 
  
26
 
  def teardown
27
 
    @@xwin.focus
28
 
    @@xwin.close!
29
 
#    Process.kill 'TERM', @editor_pipe.pid
30
 
#    @editor_pipe.close
31
 
  end
32
 
  
33
 
  def test_ewmh_active_window
34
 
    begin
35
 
      XDo::XWindow.from_active
36
 
    rescue XDo::XError
37
 
      #Standard not available
38
 
     notify $!.message
39
 
    end
40
 
  end
41
 
  
42
 
  def test_ewmh_wm_desktop
43
 
    begin
44
 
      XDo::XWindow.desktop_num
45
 
    rescue XDo::XError
46
 
      #Standard not available
47
 
      notify $!.message
48
 
    end
49
 
  end
50
 
  
51
 
  def test_ewmh_current_desktop
52
 
    begin
53
 
      XDo::XWindow.desktop
54
 
    rescue XDo::XError
55
 
      #Standard not available
56
 
      notify $!.message
57
 
    end
58
 
  end
59
 
  
60
 
  def test_exists
61
 
    assert_equal(true, XDo::XWindow.exists?(@@xwin.title))
62
 
  end
63
 
  
64
 
  def test_unfocus
65
 
    XDo::XWindow.unfocus
66
 
  #  assert_not_equal(@@xwin.id, XDo::XWindow.from_focused.id) # not supported by WM
67
 
  #  assert_raise(XDo::XError){XDo::XWindow.from_active} #Nothing's active anymore    
68
 
  end
69
 
  
70
 
  def test_active
71
 
    @@xwin.activate
72
 
    assert_equal(@@xwin.id, XDo::XWindow.from_active.id)
73
 
  end
74
 
  
75
 
  def test_focused
76
 
    @@xwin.unfocus
77
 
    @@xwin.focus
78
 
    assert_equal(@@xwin.id, XDo::XWindow.from_focused.id)
79
 
  end
80
 
  
81
 
  def test_move
82
 
    @@xwin.move(87, 57)
83
 
    assert_in_delta(87, 3, @@xwin.abs_position[0])
84
 
    assert_in_delta(57, 3, @@xwin.abs_position[1])
85
 
    # assert_equal(@@xwin.abs_position, @@xwin.rel_position) - why should this succeed?
86
 
  end
87
 
  
88
 
  def test_resize
89
 
    @@xwin.resize(500, 500)
90
 
    assert_equal([500, 500], @@xwin.size)
91
 
  end
92
 
 
93
 
  def test_map
94
 
    @@xwin.unmap
95
 
    assert_equal(nil, @@xwin.visible?)
96
 
    @@xwin.map
97
 
    assert_block("Window is not visible."){@@xwin.visible?.kind_of?(Integer)}    
98
 
  end
99
 
  
100
 
end
101