~jason-cozens/mago/unittest

« back to all changes in this revision

Viewing changes to notify-osd/notify_osd_queue.py

  • Committer: Eitan Isaacson
  • Date: 2009-03-22 23:36:18 UTC
  • Revision ID: eitan@ascender.com-20090322233618-npc5waa6pb08bc2d
Ported notify-osd to new framework.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
 
3
 
import ldtp
4
 
import ldtputils
5
 
import os, shutil
6
 
 
7
 
from time import time, gmtime, strftime
8
 
 
9
 
from desktoptesting.deskex import NotifyOSD
10
 
from desktoptesting.check import ScreenshotCompare, PASS, FAIL
11
 
 
12
 
class Bubble:
13
 
    def __init__(self, oracle, summary, body, icon):
14
 
        self.oracle = oracle
15
 
        self.summary = summary
16
 
        self.body = body
17
 
        self.icon = icon
18
 
        self.elapsed = None
19
 
        self.screeny = None
20
 
 
21
 
start_time = time()
22
 
 
23
 
test = NotifyOSD()
24
 
 
25
 
test.open(False)
26
 
 
27
 
dataXml  = ldtputils.LdtpDataFileParser(datafilename)
28
 
 
29
 
bubbles = []
30
 
 
31
 
for bubble in dataXml.gettagvalue("bubble"):
32
 
    data_file = ldtputils.LdtpDataFileParser(
33
 
        os.path.join(os.path.dirname(datafilename), bubble))
34
 
    b = Bubble(data_file.gettagvalue("oracle")[0],
35
 
               data_file.gettagvalue("summary")[0],
36
 
               data_file.gettagvalue("body")[0],
37
 
               data_file.gettagvalue("icon")[0])
38
 
    bubbles.append(b)
39
 
 
40
 
for b in bubbles:
41
 
    test.notify(b.summary, b.body, b.icon)
42
 
 
43
 
for b in bubbles:
44
 
    b.elapsed, b.screeny = test.grab_image_and_wait(b.summary)
45
 
 
46
 
status = PASS
47
 
 
48
 
for b in bubbles:
49
 
    testcheck = ScreenshotCompare(b.oracle, b.screeny)
50
 
    check = testcheck.perform_test()
51
 
    if check == FAIL:
52
 
        shutil.copy(b.screeny, "/tmp/ldtp-screenshots")
53
 
        newscreeny = os.path.join("/tmp/ldtp-screenshots", 
54
 
                                  os.path.basename(b.screeny))
55
 
        ldtp.log (newscreeny, "screenshot")
56
 
        status = FAIL
57
 
 
58
 
if status == FAIL:
59
 
    ldtp.logFailures ("Screenshots differ", False)
60
 
    ldtp.logFailures ("Screenshots differ", False, "fail") 
61
 
        
62
 
test.exit()
63
 
 
64
 
ldtp.log (str(time() - start_time), 'time')