summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/extensions/PRESUBMIT_test.py
blob: 7ac79b06820b397d1594a0b572319182c8c9a796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import unittest

import PRESUBMIT

EXTENSIONS_PATH = os.path.join('chrome', 'common', 'extensions')
DOCS_PATH = os.path.join(EXTENSIONS_PATH, 'docs')
SERVER2_PATH = os.path.join(DOCS_PATH, 'server2')
PUBLIC_PATH = os.path.join(DOCS_PATH, 'templates', 'public')
PRIVATE_PATH = os.path.join(DOCS_PATH, 'templates', 'private')
INTROS_PATH = os.path.join(DOCS_PATH, 'templates', 'intros')
ARTICLES_PATH = os.path.join(DOCS_PATH, 'templates', 'articles')

class PRESUBMITTest(unittest.TestCase):
  def testCreateIntegrationTestArgs(self):
    input_files = [
      os.path.join(EXTENSIONS_PATH, 'test.cc'),
      os.path.join(EXTENSIONS_PATH, 'test2.cc'),
      os.path.join('test', 'test.py')
    ]
    expected_files = []
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append(os.path.join('apps', 'fileSystem.html'))
    input_files.append(os.path.join(EXTENSIONS_PATH, 'api', 'file_system.idl'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append(os.path.join('extensions', 'alarms.html'))
    expected_files.append(os.path.join('apps', 'alarms.html'))
    input_files.append(os.path.join(EXTENSIONS_PATH, 'api', 'alarms.json'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append('extensions/devtools_network.html')
    input_files.append(os.path.join(EXTENSIONS_PATH,
                                    'api',
                                    'devtools',
                                    'network.json'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append(os.path.join('extensions', 'docs.html'))
    expected_files.append(os.path.join('apps', 'docs.html'))
    input_files.append(os.path.join(PUBLIC_PATH, 'extensions', 'docs.html'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append(os.path.join('extensions', 'bookmarks.html'))
    input_files.append(os.path.join(INTROS_PATH, 'bookmarks.html'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append(os.path.join('extensions', 'i18n.html'))
    expected_files.append(os.path.join('apps', 'i18n.html'))
    input_files.append(os.path.join(INTROS_PATH, 'i18n.html'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    expected_files.append(os.path.join('apps', 'about_apps.html'))
    input_files.append(os.path.join(ARTICLES_PATH, 'about_apps.html'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    input_files.append(os.path.join(PRIVATE_PATH, 'type.html'))
    self.assertEqual([ '-a' ],
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    input_files.pop()
    input_files.append(os.path.join(SERVER2_PATH, 'test.txt'))
    self.assertEqual(expected_files,
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))
    input_files.append(os.path.join(SERVER2_PATH, 'handler.py'))
    self.assertEqual([ '-a' ],
                     PRESUBMIT._CreateIntegrationTestArgs(input_files))

if __name__ == '__main__':
  unittest.main()