~mial/ubuntu/oneiric/unity/bug-791810

« back to all changes in this revision

Viewing changes to tests/ui/test-automate.vala

Import the work done so far with Compiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
 
17
 *
 
18
 */
 
19
 
 
20
using Unity;
 
21
using Unity.Testing;
 
22
using Unity.Launcher;
 
23
 
 
24
GLib.Timer gTimer;
 
25
static void
 
26
on_animation_started (Clutter.Animation? anim)
 
27
{
 
28
    //stdout.printf("Animation Started\n");
 
29
    gTimer.start ();
 
30
}
 
31
 
 
32
static void
 
33
on_animation_completed (Clutter.Animation? anim)
 
34
{
 
35
    //stdout.printf("Animation Completed\n");
 
36
    gTimer.stop ();
 
37
}
 
38
 
 
39
namespace Unity.Tests.UI
 
40
{
 
41
  public class AutomationBasicTestSuite : Object
 
42
  {
 
43
    private const string DOMAIN = "/UI/Quicklist";
 
44
 
 
45
    Unity.Testing.Window? window;
 
46
    Clutter.Stage?        stage;
 
47
 
 
48
    public AutomationBasicTestSuite ()
 
49
    {
 
50
      Logging.init_fatal_handler ();
 
51
 
 
52
      /* Testup the test window */
 
53
      window = new Unity.Testing.Window (true, 1024, 600);
 
54
      window.init_test_mode ();
 
55
      stage = window.stage;
 
56
      window.title = "Automation Tests";
 
57
      window.show_all ();
 
58
 
 
59
      Test.add_data_func (DOMAIN + "/Automation",
 
60
                          test_automation);
 
61
 
 
62
 
 
63
      /* Keep this one last, it's a dummy to clean up the state as Vala cant
 
64
       * deal with the standard TestSuite stuff properly
 
65
       */
 
66
      Test.add_data_func (DOMAIN +"/Teardown", test_teardown);
 
67
    }
 
68
 
 
69
    private void test_teardown ()
 
70
    {
 
71
      //window.destroy ();
 
72
      stage = null;
 
73
    }
 
74
 
 
75
    private void test_automation ()
 
76
    {
 
77
/*
 
78
      ObjectRegistry registry = ObjectRegistry.get_default ();
 
79
 
 
80
      Logging.init_fatal_handler ();
 
81
 
 
82
      QuicklistController qlcontroller = QuicklistController.get_default ();
 
83
      ScrollerModel scroller = registry.lookup ("UnityScrollerModel").get(0) as ScrollerModel;
 
84
 
 
85
      gTimer = new GLib.Timer();
 
86
      int DT = 2500;
 
87
      stdout.printf("\n");
 
88
 
 
89
      foreach (ScrollerChild launcher in scroller)
 
90
        {
 
91
          //launcher = scroller[i] as ScrollerChild;
 
92
          var dir = new Director (launcher.get_stage() as Clutter.Stage);
 
93
 
 
94
          qlcontroller.show_label ("Ubuntu Software Centre", launcher);
 
95
 
 
96
          Clutter.Animation? anim;
 
97
          launcher.opacity = 255;
 
98
 
 
99
 
 
100
          gTimer.start ();
 
101
          anim = launcher.animate (Clutter.AnimationMode.EASE_IN_SINE, 2500, "opacity", 0);
 
102
          //anim.started.connect (on_animation_started);
 
103
          anim.completed.connect (on_animation_completed);
 
104
          dir.do_wait_for_animation (launcher);
 
105
 
 
106
          float dt = (float)gTimer.elapsed ();
 
107
          float dt0 =  (float)DT/1000.0f;
 
108
          stdout.printf("Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", dt0, dt,
 
109
                        (dt - dt0)*100.0f/dt0);
 
110
 
 
111
          gTimer.start ();
 
112
          anim = launcher.animate (Clutter.AnimationMode.EASE_IN_SINE, 2500, "opacity", 255);
 
113
          //anim.started.connect (on_animation_started);
 
114
          anim.completed.connect (on_animation_completed);
 
115
          dir.do_wait_for_animation (launcher);
 
116
 
 
117
          dt = (float)gTimer.elapsed ();
 
118
          dt0 =  (float)DT/1000.0f;
 
119
          stdout.printf("Expected Duration: %2.3f, Observed Duration: %2.3f, Error: %2.3f%%\n", dt0, dt,
 
120
                        (dt - dt0)*100.0f/dt0);
 
121
 
 
122
 
 
123
          //dir.do_wait_for_timeout (5000);
 
124
        }
 
125
 
 
126
      //debug ("After Animation");
 
127
      qlcontroller.close_menu ();
 
128
*/
 
129
    }
 
130
  }
 
131
}