Exemplo n.º 1
0
 def test_dump_constants_aircon(self):
   """More complex tests for the dump_constants() function."""
   ignore = StringIO.StringIO()
   output = StringIO.StringIO()
   defs = []
   message = analyse.RawIRMessage(200, [
       9008, 4496, 644, 1660, 676, 530, 648, 558, 672, 1636, 646, 1660, 644,
       556, 650, 584, 626, 560, 644, 580, 628, 1680, 624, 560, 648, 1662, 644,
       582, 648, 536, 674, 530, 646, 580, 628, 560, 670, 532, 646, 562, 644,
       556, 672, 536, 648, 1662, 646, 1660, 652, 554, 644, 558, 672, 538, 644,
       560, 668, 560, 648, 1638, 668, 536, 644, 1660, 668, 532, 648, 560, 648,
       1660, 674, 554, 622, 19990, 646, 580, 624, 1660, 648, 556, 648, 558,
       674, 556, 622, 560, 644, 564, 668, 536, 646, 1662, 646, 1658, 672, 534,
       648, 558, 644, 562, 648, 1662, 644, 584, 622, 558, 648, 562, 668, 534,
       670, 536, 670, 532, 672, 536, 646, 560, 646, 558, 648, 558, 670, 534,
       650, 558, 646, 560, 646, 560, 668, 1638, 646, 1662, 646, 1660, 646,
       1660, 648
   ], ignore)
   analyse.dump_constants(message, defs, output)
   self.assertEqual(defs, [
       'const uint16_t kHdrMark = 9008;', 'const uint16_t kBitMark = 650;',
       'const uint16_t kHdrSpace = 4496;', 'const uint16_t kOneSpace = 1657;',
       'const uint16_t kZeroSpace = 554;', 'const uint16_t kSpaceGap = 19990;'
   ])
   self.assertEqual(output.getvalue(), 'Guessing key value:\n'
                    'kHdrMark   = 9008\n'
                    'kHdrSpace  = 4496\n'
                    'kBitMark   = 650\n'
                    'kOneSpace  = 1657\n'
                    'kZeroSpace = 554\n'
                    'kSpaceGap = 19990\n')
 def test_dump_constants_aircon(self):
     """More complex tests for the dump_constants() function."""
     ignore = StringIO.StringIO()
     output = StringIO.StringIO()
     defs = []
     message = analyse.RawIRMessage(200, [
         9008, 4496, 644, 1660, 676, 530, 648, 558, 672, 1636, 646, 1660,
         644, 556, 650, 584, 626, 560, 644, 580, 628, 1680, 624, 560, 648,
         1662, 644, 582, 648, 536, 674, 530, 646, 580, 628, 560, 670, 532,
         646, 562, 644, 556, 672, 536, 648, 1662, 646, 1660, 652, 554, 644,
         558, 672, 538, 644, 560, 668, 560, 648, 1638, 668, 536, 644, 1660,
         668, 532, 648, 560, 648, 1660, 674, 554, 622, 19990, 646, 580, 624,
         1660, 648, 556, 648, 558, 674, 556, 622, 560, 644, 564, 668, 536,
         646, 1662, 646, 1658, 672, 534, 648, 558, 644, 562, 648, 1662, 644,
         584, 622, 558, 648, 562, 668, 534, 670, 536, 670, 532, 672, 536,
         646, 560, 646, 558, 648, 558, 670, 534, 650, 558, 646, 560, 646,
         560, 668, 1638, 646, 1662, 646, 1660, 646, 1660, 648
     ], ignore)
     analyse.dump_constants(message, defs, output)
     self.assertEqual(defs, [
         '#define HDR_MARK 9008U', '#define BIT_MARK 676U',
         '#define HDR_SPACE 4496U', '#define ONE_SPACE 1680U',
         '#define ZERO_SPACE 584U', '#define SPACE_GAP = 19990U'
     ])
     self.assertEqual(
         output.getvalue(), 'Guessing key value:\n'
         'HDR_MARK   = 9008\n'
         'HDR_SPACE  = 4496\n'
         'BIT_MARK   = 676\n'
         'ONE_SPACE  = 1680\n'
         'ZERO_SPACE = 584\n'
         'SPACE_GAP = 19990\n')
 def test_dump_constants_simple(self):
     """Simple tests for the dump_constants() function."""
     ignore = StringIO()
     output = StringIO()
     defs = []
     message = analyse.RawIRMessage(200, [
         7930, 3952, 494, 1482, 520, 1482, 494, 1508, 494, 520, 494, 1482,
         494, 520, 494, 1482, 494, 1482, 494, 3978, 494, 520, 494, 520, 494,
         520, 494, 520, 520, 520, 494, 520, 494, 520, 494, 1482, 494
     ], ignore)
     analyse.dump_constants(message, defs, output)
     self.assertEqual(defs, [
         'const uint16_t kHdrMark = 7930;',
         'const uint16_t kBitMark = 496;',
         'const uint16_t kHdrSpace = 3965;',
         'const uint16_t kOneSpace = 1485;',
         'const uint16_t kZeroSpace = 520;'
     ])
     self.assertEqual(
         output.getvalue(), 'Guessing key value:\n'
         'kHdrMark   = 7930\n'
         'kHdrSpace  = 3965\n'
         'kBitMark   = 496\n'
         'kOneSpace  = 1485\n'
         'kZeroSpace = 520\n')
 def test_dump_constants_aircon(self):
   """More complex tests for the dump_constants() function."""
   ignore = StringIO.StringIO()
   output = StringIO.StringIO()
   defs = []
   message = analyse.RawIRMessage(200, [
       9008, 4496, 644, 1660, 676, 530, 648, 558, 672, 1636, 646, 1660, 644,
       556, 650, 584, 626, 560, 644, 580, 628, 1680, 624, 560, 648, 1662, 644,
       582, 648, 536, 674, 530, 646, 580, 628, 560, 670, 532, 646, 562, 644,
       556, 672, 536, 648, 1662, 646, 1660, 652, 554, 644, 558, 672, 538, 644,
       560, 668, 560, 648, 1638, 668, 536, 644, 1660, 668, 532, 648, 560, 648,
       1660, 674, 554, 622, 19990, 646, 580, 624, 1660, 648, 556, 648, 558,
       674, 556, 622, 560, 644, 564, 668, 536, 646, 1662, 646, 1658, 672, 534,
       648, 558, 644, 562, 648, 1662, 644, 584, 622, 558, 648, 562, 668, 534,
       670, 536, 670, 532, 672, 536, 646, 560, 646, 558, 648, 558, 670, 534,
       650, 558, 646, 560, 646, 560, 668, 1638, 646, 1662, 646, 1660, 646,
       1660, 648
   ], ignore)
   analyse.dump_constants(message, defs, output)
   self.assertEqual(defs, [
       'const uint16_t kHdrMark = 9008;', 'const uint16_t kBitMark = 650;',
       'const uint16_t kHdrSpace = 4496;', 'const uint16_t kOneSpace = 1657;',
       'const uint16_t kZeroSpace = 554;', 'const uint16_t kSpaceGap = 19990;'
   ])
   self.assertEqual(output.getvalue(), 'Guessing key value:\n'
                    'kHdrMark   = 9008\n'
                    'kHdrSpace  = 4496\n'
                    'kBitMark   = 650\n'
                    'kOneSpace  = 1657\n'
                    'kZeroSpace = 554\n'
                    'kSpaceGap = 19990\n')
 def test_dump_constants_aircon(self):
   """More complex tests for the dump_constants() function."""
   ignore = StringIO.StringIO()
   output = StringIO.StringIO()
   defs = []
   message = analyse.RawIRMessage(200, [
       9008, 4496, 644, 1660, 676, 530, 648, 558, 672, 1636, 646, 1660, 644,
       556, 650, 584, 626, 560, 644, 580, 628, 1680, 624, 560, 648, 1662, 644,
       582, 648, 536, 674, 530, 646, 580, 628, 560, 670, 532, 646, 562, 644,
       556, 672, 536, 648, 1662, 646, 1660, 652, 554, 644, 558, 672, 538, 644,
       560, 668, 560, 648, 1638, 668, 536, 644, 1660, 668, 532, 648, 560, 648,
       1660, 674, 554, 622, 19990, 646, 580, 624, 1660, 648, 556, 648, 558,
       674, 556, 622, 560, 644, 564, 668, 536, 646, 1662, 646, 1658, 672, 534,
       648, 558, 644, 562, 648, 1662, 644, 584, 622, 558, 648, 562, 668, 534,
       670, 536, 670, 532, 672, 536, 646, 560, 646, 558, 648, 558, 670, 534,
       650, 558, 646, 560, 646, 560, 668, 1638, 646, 1662, 646, 1660, 646,
       1660, 648
   ], ignore)
   analyse.dump_constants(message, defs, output)
   self.assertEqual(defs, [
       '#define HDR_MARK 9008U', '#define BIT_MARK 676U',
       '#define HDR_SPACE 4496U', '#define ONE_SPACE 1680U',
       '#define ZERO_SPACE 584U', '#define SPACE_GAP = 19990U'
   ])
   self.assertEqual(output.getvalue(), 'Guessing key value:\n'
                    'HDR_MARK   = 9008\n'
                    'HDR_SPACE  = 4496\n'
                    'BIT_MARK   = 676\n'
                    'ONE_SPACE  = 1680\n'
                    'ZERO_SPACE = 584\n'
                    'SPACE_GAP = 19990\n')
Exemplo n.º 6
0
 def test_dump_constants_simple(self):
   """Simple tests for the dump_constants() function."""
   ignore = StringIO.StringIO()
   output = StringIO.StringIO()
   defs = []
   message = analyse.RawIRMessage(200, [
       7930, 3952, 494, 1482, 520, 1482, 494, 1508, 494, 520, 494, 1482, 494,
       520, 494, 1482, 494, 1482, 494, 3978, 494, 520, 494, 520, 494, 520, 494,
       520, 520, 520, 494, 520, 494, 520, 494, 1482, 494
   ], ignore)
   analyse.dump_constants(message, defs, output)
   self.assertEqual(defs, [
       '#define HDR_MARK 7930U', '#define BIT_MARK 520U',
       '#define HDR_SPACE 3978U', '#define ONE_SPACE 1508U',
       '#define ZERO_SPACE 520U'
   ])
   self.assertEqual(output.getvalue(), 'Guessing key value:\n'
                    'HDR_MARK   = 7930\n'
                    'HDR_SPACE  = 3978\n'
                    'BIT_MARK   = 520\n'
                    'ONE_SPACE  = 1508\n'
                    'ZERO_SPACE = 520\n')
 def test_dump_constants_simple(self):
   """Simple tests for the dump_constants() function."""
   ignore = StringIO.StringIO()
   output = StringIO.StringIO()
   defs = []
   message = analyse.RawIRMessage(200, [
       7930, 3952, 494, 1482, 520, 1482, 494, 1508, 494, 520, 494, 1482, 494,
       520, 494, 1482, 494, 1482, 494, 3978, 494, 520, 494, 520, 494, 520, 494,
       520, 520, 520, 494, 520, 494, 520, 494, 1482, 494
   ], ignore)
   analyse.dump_constants(message, defs, output)
   self.assertEqual(defs, [
       'const uint16_t kHdrMark = 7930;', 'const uint16_t kBitMark = 496;',
       'const uint16_t kHdrSpace = 3965;', 'const uint16_t kOneSpace = 1485;',
       'const uint16_t kZeroSpace = 520;'
   ])
   self.assertEqual(output.getvalue(), 'Guessing key value:\n'
                    'kHdrMark   = 7930\n'
                    'kHdrSpace  = 3965\n'
                    'kBitMark   = 496\n'
                    'kOneSpace  = 1485\n'
                    'kZeroSpace = 520\n')
 def test_dump_constants_simple(self):
   """Simple tests for the dump_constants() function."""
   ignore = StringIO.StringIO()
   output = StringIO.StringIO()
   defs = []
   message = analyse.RawIRMessage(200, [
       7930, 3952, 494, 1482, 520, 1482, 494, 1508, 494, 520, 494, 1482, 494,
       520, 494, 1482, 494, 1482, 494, 3978, 494, 520, 494, 520, 494, 520, 494,
       520, 520, 520, 494, 520, 494, 520, 494, 1482, 494
   ], ignore)
   analyse.dump_constants(message, defs, output)
   self.assertEqual(defs, [
       '#define HDR_MARK 7930U', '#define BIT_MARK 520U',
       '#define HDR_SPACE 3978U', '#define ONE_SPACE 1508U',
       '#define ZERO_SPACE 520U'
   ])
   self.assertEqual(output.getvalue(), 'Guessing key value:\n'
                    'HDR_MARK   = 7930\n'
                    'HDR_SPACE  = 3978\n'
                    'BIT_MARK   = 520\n'
                    'ONE_SPACE  = 1508\n'
                    'ZERO_SPACE = 520\n')