Package Gnumed :: Package timelinelib :: Package test :: Package cases :: Module drawers
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.test.cases.drawers

  1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
  2  # 
  3  # This file is part of Timeline. 
  4  # 
  5  # Timeline is free software: you can redistribute it and/or modify 
  6  # it under the terms of the GNU General Public License as published by 
  7  # the Free Software Foundation, either version 3 of the License, or 
  8  # (at your option) any later version. 
  9  # 
 10  # Timeline is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  # GNU General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU General Public License 
 16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
 17   
 18   
 19  import unittest 
 20   
 21  from timelinelib.test.cases.wxapp import WxAppTestCase 
 22   
 23   
 24  TEXT_HEIGHT = 20 
 25  TEXT_WIDTH = 40 
26 27 28 -class describe_drawers(WxAppTestCase):
29
30 - def create_scene(self, width, height, divider_y):
31 return Scene(width, height, divider_y)
32
33 - def create_dc(self):
34 return Dc()
35
36 - def install_gettext(self):
37 import gettext 38 from timelinelib.config.paths import LOCALE_DIR 39 from timelinelib.meta.about import APPLICATION_NAME 40 gettext.install(APPLICATION_NAME.lower(), LOCALE_DIR, unicode=True)
41
42 43 -class Dc:
44
45 - def __init__(self):
46 self._set_pen_call_count = 0 47 self._set_draw_line_call_count = 0 48 self._set_draw_text_call_count = 0 49 self._font = None 50 self._text_foreground = None 51 self._text = None 52 self._text_x = None 53 self._text_y = None
54 55 @property
56 - def pen_call_count(self):
57 return self._set_pen_call_count
58 59 @property
60 - def draw_line_call_count(self):
61 return self._set_draw_line_call_count
62 63 @property
64 - def draw_text_call_count(self):
65 return self._set_draw_text_call_count
66 67 @property
68 - def x1(self):
69 return self._x1
70 71 @property
72 - def y1(self):
73 return self._y1
74 75 @property
76 - def x2(self):
77 return self._x2
78 79 @property
80 - def y2(self):
81 return self._y2
82 83 @property
84 - def font(self):
85 return self._font
86 87 @property
88 - def text_foreground(self):
89 return self._text_foreground
90 91 @property
92 - def text(self):
93 return self._text
94 95 @property
96 - def text_x(self):
97 return self._text_x
98 99 @property
100 - def text_y(self):
101 return self._text_y
102
103 - def SetPen(self, pen):
104 self._set_pen_call_count += 1
105
106 - def SetTextForeground(self, color):
107 self._text_foreground = color
108
109 - def DrawLine(self, x1, y1, x2, y2):
110 self._x1 = x1 111 self._y1 = y1 112 self._x2 = x2 113 self._y2 = y2 114 self._set_draw_line_call_count += 1
115
116 - def DrawText(self, text, x, y):
117 self._text = text 118 self._text_x = x 119 self._text_y = y 120 self._set_draw_text_call_count += 1
121
122 - def GetTextExtent(self, text):
123 return TEXT_WIDTH, TEXT_HEIGHT
124
125 - def SetFont(self, font):
126 self._font = font
127
128 129 -class Scene:
130
131 - def __init__(self, width, height, divider_y):
132 self._width = width 133 self._height = height 134 self._divider_y = divider_y
135 136 @property
137 - def width(self):
138 return self._width
139 140 @property
141 - def height(self):
142 return self._height
143 144 @property
145 - def divider_y(self):
146 return self._divider_y
147
148 - def x_pos_for_time(self, time):
149 return 100
150
151 - def minor_strip_is_day(self):
152 return True
153
154 155 -def install_gettext():
156 import gettext 157 from timelinelib.config.paths import LOCALE_DIR 158 from timelinelib.meta.about import APPLICATION_NAME 159 gettext.install(APPLICATION_NAME.lower(), LOCALE_DIR, unicode=True)
160