|
@@ -277,6 +277,15 @@ class SrcFixedPDOTestCase(unittest.TestCase):
|
277
|
277
|
"fixed\n\tv: 5.00 V\n\ti: 1.50 A")
|
278
|
278
|
|
279
|
279
|
|
|
280
|
+class TypeCVirtualPDOTestCase(unittest.TestCase):
|
|
281
|
+
|
|
282
|
+ def setUp(self):
|
|
283
|
+ self.obj_1p5a = pdbuddy.TypeCVirtualPDO(1500)
|
|
284
|
+
|
|
285
|
+ def test_str_1p5a(self):
|
|
286
|
+ self.assertEqual(str(self.obj_1p5a), "typec_virtual\n\ti: 1.50 A")
|
|
287
|
+
|
|
288
|
+
|
280
|
289
|
class ReadPDOTestCase(unittest.TestCase):
|
281
|
290
|
|
282
|
291
|
def setUp(self):
|
|
@@ -286,6 +295,7 @@ class ReadPDOTestCase(unittest.TestCase):
|
286
|
295
|
False, False, 0, 5000, 1500)
|
287
|
296
|
self.unknown_zero = pdbuddy.UnknownPDO(value=0x00000000)
|
288
|
297
|
self.unknown_notzero = pdbuddy.UnknownPDO(value=0xFFFFFFFF)
|
|
298
|
+ self.typec_virtual = pdbuddy.TypeCVirtualPDO(1500)
|
289
|
299
|
|
290
|
300
|
def test_read_src_fixed_everything(self):
|
291
|
301
|
rp_src_fixed_everything = pdbuddy.read_pdo([b"PDO 1: fixed",
|
|
@@ -319,6 +329,11 @@ class ReadPDOTestCase(unittest.TestCase):
|
319
|
329
|
rp_unknown_notzero = pdbuddy.read_pdo([b"PDO 1: FFFFFFFF"])
|
320
|
330
|
self.assertEqual(self.unknown_notzero, rp_unknown_notzero)
|
321
|
331
|
|
|
332
|
+ def test_read_typec_virtual(self):
|
|
333
|
+ rp_typec_virtual = pdbuddy.read_pdo([b"PDO 5: typec_virtual",
|
|
334
|
+ b"\ti: 1.50 A"])
|
|
335
|
+ self.assertEqual(self.typec_virtual, rp_typec_virtual)
|
|
336
|
+
|
322
|
337
|
def test_read_none(self):
|
323
|
338
|
none_pdo = pdbuddy.read_pdo([b"No Source_Capabilities"])
|
324
|
339
|
self.assertEqual(none_pdo, None)
|
|
@@ -333,6 +348,7 @@ class ReadPDOListTestCase(unittest.TestCase):
|
333
|
348
|
False, False, 0, 5000, 1500)
|
334
|
349
|
self.unknown_zero = pdbuddy.UnknownPDO(value=0x00000000)
|
335
|
350
|
self.unknown_notzero = pdbuddy.UnknownPDO(value=0xFFFFFFFF)
|
|
351
|
+ self.typec_virtual = pdbuddy.TypeCVirtualPDO(1500)
|
336
|
352
|
|
337
|
353
|
def test_read_pdo_list(self):
|
338
|
354
|
# It's not a legal list for USB Power Delivery, but it works fine for
|
|
@@ -350,13 +366,16 @@ class ReadPDOListTestCase(unittest.TestCase):
|
350
|
366
|
b"\tv: 5.00 V",
|
351
|
367
|
b"\ti: 1.50 A",
|
352
|
368
|
b"PDO 3: 00000000",
|
353
|
|
- b"PDO 4: FFFFFFFF"]
|
|
369
|
+ b"PDO 4: FFFFFFFF",
|
|
370
|
+ b"PDO 5: typec_virtual",
|
|
371
|
+ b"\ti: 1.50 A"]
|
354
|
372
|
pdo_list = pdbuddy.read_pdo_list(text)
|
355
|
373
|
|
356
|
374
|
self.assertEqual(pdo_list[0], self.src_fixed_everything)
|
357
|
375
|
self.assertEqual(pdo_list[1], self.src_fixed_minimal)
|
358
|
376
|
self.assertEqual(pdo_list[2], self.unknown_zero)
|
359
|
377
|
self.assertEqual(pdo_list[3], self.unknown_notzero)
|
|
378
|
+ self.assertEqual(pdo_list[4], self.typec_virtual)
|
360
|
379
|
|
361
|
380
|
|
362
|
381
|
class PDOListCalculationsTestCase(unittest.TestCase):
|
|
@@ -382,6 +401,10 @@ class PDOListCalculationsTestCase(unittest.TestCase):
|
382
|
401
|
False, False, 0, 20000, 2250)
|
383
|
402
|
self.src_fixed_20v_5a = pdbuddy.SrcFixedPDO(False, False, False, False,
|
384
|
403
|
False, 0, 20000, 5000)
|
|
404
|
+ self.typec_virtual_1p5a = pdbuddy.TypeCVirtualPDO(1500)
|
|
405
|
+
|
|
406
|
+ def test_calculate_pdp_typec_virtual(self):
|
|
407
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.typec_virtual_1p5a]), 7.5)
|
385
|
408
|
|
386
|
409
|
def test_calculate_pdp_15w(self):
|
387
|
410
|
self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a]), 15)
|
|
@@ -411,6 +434,7 @@ class PDOListCalculationsTestCase(unittest.TestCase):
|
411
|
434
|
def test_follows_power_rules_true(self):
|
412
|
435
|
# <= 15 W
|
413
|
436
|
self.assertTrue(pdbuddy.follows_power_rules([]))
|
|
437
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.typec_virtual_1p5a]))
|
414
|
438
|
self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_1p5a]))
|
415
|
439
|
self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a]))
|
416
|
440
|
self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|