GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / native_client_sdk / src / tools / tests / create_html_test.py
blobdd37338d3671b2d9ad592ce407247096733be333
1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 import os
6 import unittest
7 import shutil
8 import sys
9 import tempfile
11 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
12 PARENT_DIR = os.path.dirname(SCRIPT_DIR)
13 CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(PARENT_DIR)))
14 MOCK_DIR = os.path.join(CHROME_SRC, 'third_party', 'pymock')
16 sys.path.append(PARENT_DIR)
17 sys.path.append(MOCK_DIR)
19 import create_html
20 import mock
22 class TestCreateHtml(unittest.TestCase):
23 def setUp(self):
24 self.tempdir = None
26 def tearDown(self):
27 if self.tempdir:
28 shutil.rmtree(self.tempdir)
30 def testBadInput(self):
31 # Non-existant file
32 self.assertRaises(create_html.Error, create_html.main, ['foo.nexe'])
33 # Existing file with wrong extension
34 self.assertRaises(create_html.Error, create_html.main, [__file__])
35 # Existing directory
36 self.assertRaises(create_html.Error, create_html.main, [PARENT_DIR])
38 def testCreatesOutput(self):
39 self.tempdir = tempfile.mkdtemp("_sdktest")
40 expected_html = os.path.join(self.tempdir, 'foo.html')
41 nmf_file = os.path.join(self.tempdir, 'foo.nmf')
42 with mock.patch('sys.stdout'):
43 with mock.patch('os.path.exists'):
44 with mock.patch('os.path.isfile'):
45 options = mock.MagicMock(return_value=False)
46 options.output = None
47 create_html.CreateHTML([nmf_file], options)
48 # Assert that the file was created
49 self.assertTrue(os.path.exists(expected_html))
50 # Assert that nothing else was created
51 self.assertEqual(os.listdir(self.tempdir),
52 [os.path.basename(expected_html)])
55 if __name__ == '__main__':
56 unittest.main()