OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import unittest | 7 import unittest |
8 | 8 |
9 from telemetry import test | 9 from telemetry import benchmark |
10 from telemetry.core import bitmap | 10 from telemetry.core import bitmap |
11 from telemetry.core import util | 11 from telemetry.core import util |
12 from telemetry.core import video | 12 from telemetry.core import video |
13 from telemetry.core.platform import android_platform_backend | 13 from telemetry.core.platform import android_platform_backend |
14 from telemetry.unittest import system_stub | 14 from telemetry.unittest import system_stub |
15 | 15 |
16 class MockAdbCommands(object): | 16 class MockAdbCommands(object): |
17 def CanAccessProtectedFileContents(self): | 17 def CanAccessProtectedFileContents(self): |
18 return True | 18 return True |
19 | 19 |
20 class MockDevice(object): | 20 class MockDevice(object): |
21 def __init__(self, mock_adb_commands): | 21 def __init__(self, mock_adb_commands): |
22 self.old_interface = mock_adb_commands | 22 self.old_interface = mock_adb_commands |
23 | 23 |
24 class VideoTest(unittest.TestCase) : | 24 class VideoTest(unittest.TestCase) : |
25 def setUp(self): | 25 def setUp(self): |
26 self._stubs = system_stub.Override(android_platform_backend, | 26 self._stubs = system_stub.Override(android_platform_backend, |
27 ['perf_control', 'thermal_throttle']) | 27 ['perf_control', 'thermal_throttle']) |
28 | 28 |
29 def tearDown(self): | 29 def tearDown(self): |
30 self._stubs.Restore() | 30 self._stubs.Restore() |
31 | 31 |
32 @test.Disabled | 32 @benchmark.Disabled |
33 def testFramesFromMp4(self): | 33 def testFramesFromMp4(self): |
34 mock_adb = MockDevice(MockAdbCommands()) | 34 mock_adb = MockDevice(MockAdbCommands()) |
35 backend = android_platform_backend.AndroidPlatformBackend(mock_adb, False) | 35 backend = android_platform_backend.AndroidPlatformBackend(mock_adb, False) |
36 | 36 |
37 try: | 37 try: |
38 backend.InstallApplication('avconv') | 38 backend.InstallApplication('avconv') |
39 finally: | 39 finally: |
40 if not backend.CanLaunchApplication('avconv'): | 40 if not backend.CanLaunchApplication('avconv'): |
41 logging.warning('Test not supported on this platform') | 41 logging.warning('Test not supported on this platform') |
42 return # pylint: disable=W0150 | 42 return # pylint: disable=W0150 |
(...skipping 13 matching lines...) Expand all Loading... |
56 video_obj = video.Video(backend, vid) | 56 video_obj = video.Video(backend, vid) |
57 | 57 |
58 # Calling _FramesFromMp4 should return all frames. | 58 # Calling _FramesFromMp4 should return all frames. |
59 # pylint: disable=W0212 | 59 # pylint: disable=W0212 |
60 for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4(vid)): | 60 for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4(vid)): |
61 timestamp, bmp = timestamp_bitmap | 61 timestamp, bmp = timestamp_bitmap |
62 self.assertEquals(timestamp, expected_timestamps[i]) | 62 self.assertEquals(timestamp, expected_timestamps[i]) |
63 expected_bitmap = bitmap.Bitmap.FromPngFile(os.path.join( | 63 expected_bitmap = bitmap.Bitmap.FromPngFile(os.path.join( |
64 util.GetUnittestDataDir(), 'frame%d.png' % i)) | 64 util.GetUnittestDataDir(), 'frame%d.png' % i)) |
65 self.assertTrue(expected_bitmap.IsEqual(bmp)) | 65 self.assertTrue(expected_bitmap.IsEqual(bmp)) |
OLD | NEW |