| 1 |
import pytest |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
def setup_test(): |
| 6 |
"""Setup test environment.""" |
| 7 |
from _thread import start_new_thread |
| 8 |
from time import sleep |
| 9 |
|
| 10 |
class Subprocess: |
| 11 |
"""Mock subprocess class to simulate sending commands.""" |
| 12 |
|
| 13 |
def send(self, bytes_): |
| 14 |
start_new_thread(test, (bytes_,)) |
| 15 |
|
| 16 |
class Worker: |
| 17 |
"""Mock worker class to simulate subprocess.""" |
| 18 |
|
| 19 |
def __init__(self): |
| 20 |
self.subprocess = Subprocess() |
| 21 |
|
| 22 |
def safe_send(self, bytes_): |
| 23 |
self.subprocess.send(bytes_) |
| 24 |
return True |
| 25 |
|
| 26 |
config.initcfg() |
| 27 |
lang.init() |
| 28 |
app = BaseApp(0) |
| 29 |
|
| 30 |
if "--crt" in sys.argv[1:]: |
| 31 |
setcfg("measurement_mode", "c") |
| 32 |
else: |
| 33 |
setcfg("measurement_mode", "l") |
| 34 |
|
| 35 |
app.TopWindow = DisplayAdjustmentFrame(start_timer=False) |
| 36 |
app.TopWindow.worker = Worker() |
| 37 |
app.TopWindow.Show() |
| 38 |
i = 0 |
| 39 |
|
| 40 |
yield app, i |
| 41 |
|
| 42 |
start_new_thread(test, ()) |
| 43 |
app.MainLoop() |
| 44 |
|
| 45 |
|
| 46 |
@pytest.mark.skip(reason="TODO: This test is moved from the module, properly implement it.") |
| 47 |
def test_from_modules(bytes_=None): |
| 48 |
global i |
| 49 |
# 0 = dispcal -v -yl |
| 50 |
# 1 = dispcal -v -yl -b130 |
| 51 |
# 2 = dispcal -v -yl -B0.5 |
| 52 |
# 3 = dispcal -v -yl -t5200 |
| 53 |
# 4 = dispcal -v -yl -t5200 -b130 -B0.5 |
| 54 |
menu = r""" |
| 55 |
Press 1 .. 7 |
| 56 |
1) Black level (CRT: Offset/Brightness) |
| 57 |
2) White point (Color temperature, R,G,B, Gain/Contrast) |
| 58 |
3) White level (CRT: Gain/Contrast, LCD: Brightness/Backlight) |
| 59 |
4) Black point (R,G,B, Offset/Brightness) |
| 60 |
5) Check all |
| 61 |
6) Measure and set ambient for viewing condition adjustment |
| 62 |
7) Continue on to calibration |
| 63 |
8) Exit |
| 64 |
""" |
| 65 |
if bytes_ == " ": |
| 66 |
txt = "\n" + menu |
| 67 |
elif bytes_ == "1": |
| 68 |
# Black level |
| 69 |
txt = [ |
| 70 |
r"""Doing some initial measurements |
| 71 |
Black = XYZ 0.19 0.20 0.28 |
| 72 |
Grey = XYZ 27.20 27.79 24.57 |
| 73 |
White = XYZ 126.48 128.71 112.75 |
| 74 |
|
| 75 |
Adjust CRT brightness to get target level. Press space when done. |
| 76 |
Target 1.29 |
| 77 |
/ Current 2.02 -""", |
| 78 |
r"""Doing some initial measurements |
| 79 |
Black = XYZ 0.19 0.20 0.29 |
| 80 |
Grey = XYZ 27.11 27.76 24.72 |
| 81 |
White = XYZ 125.91 128.38 113.18 |
| 82 |
|
| 83 |
Adjust CRT brightness to get target level. Press space when done. |
| 84 |
Target 1.28 |
| 85 |
/ Current 2.02 -""", |
| 86 |
r"""Doing some initial measurements |
| 87 |
Black = XYZ 0.19 0.21 0.28 |
| 88 |
Grey = XYZ 27.08 27.72 24.87 |
| 89 |
White = XYZ 125.47 127.86 113.60 |
| 90 |
|
| 91 |
Adjust CRT brightness to get target level. Press space when done. |
| 92 |
Target 1.28 |
| 93 |
/ Current 2.02 -""", |
| 94 |
r"""Doing some initial measurements |
| 95 |
Black = XYZ 0.19 0.20 0.29 |
| 96 |
Grey = XYZ 27.11 27.77 25.01 |
| 97 |
White = XYZ 125.21 127.80 113.90 |
| 98 |
|
| 99 |
Adjust CRT brightness to get target level. Press space when done. |
| 100 |
Target 1.28 |
| 101 |
/ Current 2.03 -""", |
| 102 |
r"""Doing some initial measurements |
| 103 |
Black = XYZ 0.19 0.20 0.30 |
| 104 |
Grey = XYZ 23.56 24.14 21.83 |
| 105 |
White = XYZ 124.87 130.00 112.27 |
| 106 |
|
| 107 |
Adjust CRT brightness to get target level. Press space when done. |
| 108 |
Target 1.28 |
| 109 |
/ Current 1.28""", |
| 110 |
][i] |
| 111 |
elif bytes_ == "2": |
| 112 |
# White point |
| 113 |
txt = [ |
| 114 |
r"""Doing some initial measurements |
| 115 |
Red = XYZ 81.08 39.18 2.41 |
| 116 |
Green = XYZ 27.63 80.13 10.97 |
| 117 |
Blue = XYZ 18.24 9.90 99.75 |
| 118 |
White = XYZ 126.53 128.96 112.57 |
| 119 |
|
| 120 |
Adjust R,G & B gain to desired white point. Press space when done. |
| 121 |
Initial Br 128.96, x 0.3438 , y 0.3504 , VDT 5152K DE 2K 4.7 |
| 122 |
/ Current Br 128.85, x 0.3439-, y 0.3502+ VDT 5151K DE 2K 4.8 R- G++ B-""", |
| 123 |
r"""Doing some initial measurements |
| 124 |
Red = XYZ 80.48 38.87 2.43 |
| 125 |
Green = XYZ 27.58 79.99 10.96 |
| 126 |
Blue = XYZ 18.34 9.93 100.24 |
| 127 |
White = XYZ 125.94 128.32 113.11 |
| 128 |
|
| 129 |
Adjust R,G & B gain to desired white point. Press space when done. |
| 130 |
Initial Br 130.00, x 0.3428 , y 0.3493 , VDT 5193K DE 2K 4.9 |
| 131 |
/ Current Br 128.39, x 0.3428-, y 0.3496+ VDT 5190K DE 2K 4.7 R- G++ B-""", |
| 132 |
r"""Doing some initial measurements |
| 133 |
Red = XYZ 80.01 38.57 2.44 |
| 134 |
Green = XYZ 27.51 79.85 10.95 |
| 135 |
Blue = XYZ 18.45 9.94 100.77 |
| 136 |
White = XYZ 125.48 127.88 113.70 |
| 137 |
|
| 138 |
Adjust R,G & B gain to desired white point. Press space when done. |
| 139 |
Initial Br 127.88, x 0.3419 , y 0.3484 , VDT 5232K DE 2K 5.0 |
| 140 |
/ Current Br 127.87, x 0.3419-, y 0.3485+ VDT 5231K DE 2K 4.9 R- G++ B-""", |
| 141 |
r"""Doing some initial measurements |
| 142 |
Red = XYZ 79.69 38.48 2.44 |
| 143 |
Green = XYZ 27.47 79.76 10.95 |
| 144 |
Blue = XYZ 18.50 9.95 101.06 |
| 145 |
White = XYZ 125.08 127.71 113.91 |
| 146 |
|
| 147 |
Adjust R,G & B gain to get target x,y. Press space when done. |
| 148 |
Target Br 127.71, x 0.3401 , y 0.3540 |
| 149 |
/ Current Br 127.70, x 0.3412-, y 0.3481+ DE 4.8 R- G++ B-""", |
| 150 |
r"""Doing some initial measurements |
| 151 |
Red = XYZ 79.47 38.41 2.44 |
| 152 |
Green = XYZ 27.41 79.72 10.94 |
| 153 |
Blue = XYZ 18.52 9.96 101.20 |
| 154 |
White = XYZ 124.87 130.00 112.27 |
| 155 |
|
| 156 |
Adjust R,G & B gain to get target x,y. Press space when done. |
| 157 |
Target Br 130.00, x 0.3401 , y 0.3540 |
| 158 |
/ Current Br 130.00, x 0.3401=, y 0.3540= DE 0.0 R= G= B=""", |
| 159 |
][i] |
| 160 |
elif bytes_ == "3": |
| 161 |
# White level |
| 162 |
txt = [ |
| 163 |
r"""Doing some initial measurements |
| 164 |
White = XYZ 126.56 128.83 112.65 |
| 165 |
|
| 166 |
Adjust CRT Contrast or LCD Brightness to desired level. Press space when done. |
| 167 |
Initial 128.83 |
| 168 |
/ Current 128.85""", |
| 169 |
r"""Doing some initial measurements |
| 170 |
White = XYZ 125.87 128.23 113.43 |
| 171 |
|
| 172 |
Adjust CRT Contrast or LCD Brightness to get target level. Press space when done. |
| 173 |
Target 130.00 |
| 174 |
/ Current 128.24 +""", |
| 175 |
r"""Doing some initial measurements |
| 176 |
White = XYZ 125.33 127.94 113.70 |
| 177 |
|
| 178 |
Adjust CRT Contrast or LCD Brightness to desired level. Press space when done. |
| 179 |
Initial 127.94 |
| 180 |
/ Current 127.88""", |
| 181 |
r"""Doing some initial measurements |
| 182 |
White = XYZ 125.00 127.72 114.03 |
| 183 |
|
| 184 |
Adjust CRT Contrast or LCD Brightness to desired level. Press space when done. |
| 185 |
Initial 127.72 |
| 186 |
/ Current 127.69""", |
| 187 |
r"""Doing some initial measurements |
| 188 |
White = XYZ 124.87 130.00 112.27 |
| 189 |
|
| 190 |
Adjust CRT Contrast or LCD Brightness to get target level. Press space when done. |
| 191 |
Target 130.00 |
| 192 |
/ Current 130.00""", |
| 193 |
][i] |
| 194 |
elif bytes_ == "4": |
| 195 |
# Black point |
| 196 |
txt = [ |
| 197 |
r"""Doing some initial measurements |
| 198 |
Black = XYZ 0.19 0.21 0.29 |
| 199 |
Grey = XYZ 27.25 27.83 24.52 |
| 200 |
White = XYZ 126.60 128.86 112.54 |
| 201 |
|
| 202 |
Adjust R,G & B offsets to get target x,y. Press space when done. |
| 203 |
Target Br 1.29, x 0.3440 , y 0.3502 |
| 204 |
/ Current Br 2.03, x 0.3409+, y 0.3484+ DE 1.7 R++ G+ B-""", |
| 205 |
r"""Doing some initial measurements |
| 206 |
Black = XYZ 0.19 0.21 0.29 |
| 207 |
Grey = XYZ 27.19 27.87 24.94 |
| 208 |
White = XYZ 125.83 128.16 113.57 |
| 209 |
|
| 210 |
Adjust R,G & B offsets to get target x,y. Press space when done. |
| 211 |
Target Br 1.28, x 0.3423 , y 0.3487 |
| 212 |
/ Current Br 2.03, x 0.3391+, y 0.3470+ DE 1.7 R++ G+ B-""", |
| 213 |
r"""Doing some initial measurements |
| 214 |
Black = XYZ 0.19 0.21 0.29 |
| 215 |
Grey = XYZ 27.14 27.79 24.97 |
| 216 |
White = XYZ 125.49 127.89 113.90 |
| 217 |
|
| 218 |
Adjust R,G & B offsets to get target x,y. Press space when done. |
| 219 |
Target Br 1.28, x 0.3417 , y 0.3482 |
| 220 |
/ Current Br 2.02, x 0.3386+, y 0.3466+ DE 1.7 R++ G+ B-""", |
| 221 |
r"""Doing some initial measurements |
| 222 |
Black = XYZ 0.19 0.21 0.30 |
| 223 |
Grey = XYZ 27.10 27.79 25.12 |
| 224 |
White = XYZ 125.12 127.68 114.09 |
| 225 |
|
| 226 |
Adjust R,G & B offsets to get target x,y. Press space when done. |
| 227 |
Target Br 1.28, x 0.3401 , y 0.3540 |
| 228 |
/ Current Br 2.04, x 0.3373+, y 0.3465+ DE 4.4 R+ G++ B-""", |
| 229 |
r"""Doing some initial measurements |
| 230 |
Black = XYZ 0.19 0.21 0.29 |
| 231 |
Grey = XYZ 23.56 24.14 21.83 |
| 232 |
White = XYZ 124.87 130.00 112.27 |
| 233 |
|
| 234 |
Adjust R,G & B offsets to get target x,y. Press space when done. |
| 235 |
Target Br 1.28, x 0.3401 , y 0.3540 |
| 236 |
/ Current Br 1.28, x 0.3401=, y 0.3540= DE 0.0 R= G= B=""", |
| 237 |
][i] |
| 238 |
elif bytes_ == "5": |
| 239 |
# Check all |
| 240 |
txt = [ |
| 241 |
r"""Doing check measurements |
| 242 |
Black = XYZ 0.19 0.20 0.29 |
| 243 |
Grey = XYZ 27.22 27.80 24.49 |
| 244 |
White = XYZ 126.71 128.91 112.34 |
| 245 |
1% = XYZ 1.94 1.98 1.76 |
| 246 |
|
| 247 |
Current Brightness = 128.91 |
| 248 |
Target 50% Level = 24.42, Current = 27.80, error = 2.6% |
| 249 |
Target Near Black = 1.29, Current = 2.02, error = 0.6% |
| 250 |
Current white = x 0.3443, y 0.3503, VDT 5137K DE 2K 5.0 |
| 251 |
Target black = x 0.3443, y 0.3503, Current = x 0.3411, y 0.3486, error = 1.73 DE |
| 252 |
|
| 253 |
Press 1 .. 7""", |
| 254 |
r"""Doing check measurements |
| 255 |
Black = XYZ 0.19 0.21 0.29 |
| 256 |
Grey = XYZ 27.10 27.75 24.85 |
| 257 |
White = XYZ 125.78 128.17 113.53 |
| 258 |
1% = XYZ 1.93 1.98 1.79 |
| 259 |
|
| 260 |
Target Brightness = 130.00, Current = 128.17, error = -1.4% |
| 261 |
Target 50% Level = 24.28, Current = 27.75, error = 2.7% |
| 262 |
Target Near Black = 1.28, Current = 2.02, error = 0.6% |
| 263 |
Current white = x 0.3423, y 0.3488, VDT 5215K DE 2K 4.9 |
| 264 |
Target black = x 0.3423, y 0.3488, Current = x 0.3391, y 0.3467, error = 1.69 DE |
| 265 |
|
| 266 |
Press 1 .. 7""", |
| 267 |
r"""Doing check measurements |
| 268 |
Black = XYZ 0.19 0.21 0.29 |
| 269 |
Grey = XYZ 27.09 27.74 24.95 |
| 270 |
White = XYZ 125.32 127.78 113.82 |
| 271 |
1% = XYZ 1.93 1.98 1.80 |
| 272 |
|
| 273 |
Current Brightness = 127.78 |
| 274 |
Target 50% Level = 24.21, Current = 27.74, error = 2.8% |
| 275 |
Target Near Black = 1.28, Current = 2.02, error = 0.6% |
| 276 |
Current white = x 0.3415, y 0.3483, VDT 5243K DE 2K 4.9 |
| 277 |
Target black = x 0.3415, y 0.3483, Current = x 0.3386, y 0.3465, error = 1.55 DE |
| 278 |
|
| 279 |
Press 1 .. 7""", |
| 280 |
r"""Doing check measurements |
| 281 |
Black = XYZ 0.19 0.20 0.29 |
| 282 |
Grey = XYZ 26.98 27.68 24.97 |
| 283 |
White = XYZ 125.00 127.56 113.99 |
| 284 |
1% = XYZ 1.92 1.97 1.80 |
| 285 |
|
| 286 |
Current Brightness = 127.56 |
| 287 |
Target 50% Level = 24.17, Current = 27.68, error = 2.8% |
| 288 |
Target Near Black = 1.28, Current = 2.02, error = 0.6% |
| 289 |
Target white = x 0.3401, y 0.3540, Current = x 0.3410, y 0.3480, error = 4.83 DE |
| 290 |
Target black = x 0.3401, y 0.3540, Current = x 0.3372, y 0.3464, error = 4.48 DE |
| 291 |
|
| 292 |
Press 1 .. 7""", |
| 293 |
r"""Doing check measurements |
| 294 |
Black = XYZ 0.19 0.21 0.29 |
| 295 |
Grey = XYZ 23.56 24.14 21.83 |
| 296 |
White = XYZ 124.87 130.00 112.27 |
| 297 |
1% = XYZ 1.92 1.97 1.80 |
| 298 |
|
| 299 |
Target Brightness = 130.00, Current = 130.00, error = 0.0% |
| 300 |
Target 50% Level = 24.14, Current = 24.14, error = 0.0% |
| 301 |
Target Near Black = 1.27, Current = 1.27, error = 0.0% |
| 302 |
Target white = x 0.3401, y 0.3540, Current = x 0.3401, y 0.3540, error = 0.00 DE |
| 303 |
Target black = x 0.3401, y 0.3540, Current = x 0.3401, y 0.3540, error = 0.00 DE |
| 304 |
|
| 305 |
Press 1 .. 7""", |
| 306 |
][i] |
| 307 |
elif bytes_ == "7" or not bytes_: |
| 308 |
if bytes_ == "7": |
| 309 |
if i < 4: |
| 310 |
i += 1 |
| 311 |
else: |
| 312 |
i -= 4 |
| 313 |
wx.CallAfter(app.TopWindow.reset) |
| 314 |
txt = ( |
| 315 |
[ |
| 316 |
r"""Setting up the instrument |
| 317 |
Place instrument on test window. |
| 318 |
Hit Esc or Q to give up, any other key to continue: |
| 319 |
Display type is LCD |
| 320 |
Target white = native white point |
| 321 |
Target white brightness = native brightness |
| 322 |
Target black brightness = native brightness |
| 323 |
Target advertised gamma = 2.400000""", |
| 324 |
r"""Setting up the instrument |
| 325 |
Place instrument on test window. |
| 326 |
Hit Esc or Q to give up, any other key to continue: |
| 327 |
Display type is LCD |
| 328 |
Target white = native white point |
| 329 |
Target white brightness = 130.000000 cd/m^2 |
| 330 |
Target black brightness = native brightness |
| 331 |
Target advertised gamma = 2.400000""", |
| 332 |
r"""Setting up the instrument |
| 333 |
Place instrument on test window. |
| 334 |
Hit Esc or Q to give up, any other key to continue: |
| 335 |
Display type is LCD |
| 336 |
Target white = native white point |
| 337 |
Target white brightness = native brightness |
| 338 |
Target black brightness = 0.500000 cd/m^2 |
| 339 |
Target advertised gamma = 2.400000""", |
| 340 |
r"""Setting up the instrument |
| 341 |
Place instrument on test window. |
| 342 |
Hit Esc or Q to give up, any other key to continue: |
| 343 |
Display type is LCD |
| 344 |
Target white = 5200.000000 degrees kelvin Daylight spectrum |
| 345 |
Target white brightness = native brightness |
| 346 |
Target black brightness = native brightness |
| 347 |
Target advertised gamma = 2.400000""", |
| 348 |
r"""Setting up the instrument |
| 349 |
Place instrument on test window. |
| 350 |
Hit Esc or Q to give up, any other key to continue: |
| 351 |
Display type is CRT |
| 352 |
Target white = 5200.000000 degrees kelvin Daylight spectrum |
| 353 |
Target white brightness = 130.000000 cd/m^2 |
| 354 |
Target black brightness = 0.500000 cd/m^2 |
| 355 |
Target advertised gamma = 2.400000""", |
| 356 |
][i] |
| 357 |
+ r""" |
| 358 |
|
| 359 |
Display adjustment menu:""" |
| 360 |
+ menu |
| 361 |
) |
| 362 |
elif bytes_ == "8": |
| 363 |
wx.CallAfter(app.TopWindow.Close) |
| 364 |
return |
| 365 |
else: |
| 366 |
return |
| 367 |
for line in txt.split("\n"): |
| 368 |
sleep(0.0625) |
| 369 |
wx.CallAfter(app.TopWindow.write, line) |
| 370 |
print(line) |