1#!/usr/bin/env python
2
3# Copyright (c) 2012 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""
8Verifies the Info.plist preprocessor functionality.
9"""
10
11import TestGyp
12
13import sys
14
15if sys.platform == 'darwin':
16  print "This test is currently disabled: https://crbug.com/483696."
17  sys.exit(0)
18
19  test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
20
21  CHDIR = 'infoplist-process'
22  INFO_PLIST_PATH = 'Test.app/Contents/Info.plist'
23
24  # First process both keys.
25  test.set_configuration('One')
26  test.run_gyp('test1.gyp', chdir=CHDIR)
27  test.build('test1.gyp', test.ALL, chdir=CHDIR)
28  info_plist = test.built_file_path(INFO_PLIST_PATH, chdir=CHDIR)
29  test.must_exist(info_plist)
30  test.must_contain(info_plist, 'Foo')
31  test.must_contain(info_plist, 'Bar')
32
33  # Then process a single key.
34  test.set_configuration('Two')
35  test.run_gyp('test2.gyp', chdir=CHDIR)
36  test.build('test2.gyp', chdir=CHDIR)
37  info_plist = test.built_file_path(INFO_PLIST_PATH, chdir=CHDIR)
38  test.must_exist(info_plist)
39  test.must_contain(info_plist, 'com.google.Test')  # Normal expansion works.
40  test.must_contain(info_plist, 'Foo (Bar)')
41  test.must_contain(info_plist, 'PROCESSED_KEY2')
42
43  # Then turn off the processor.
44  test.set_configuration('Three')
45  test.run_gyp('test3.gyp', chdir=CHDIR)
46  test.build('test3.gyp', chdir=CHDIR)
47  info_plist = test.built_file_path('Test App.app/Contents/Info.plist',
48                                    chdir=CHDIR)
49  test.must_exist(info_plist)
50  test.must_contain(info_plist, 'com.google.Test')  # Normal expansion works.
51  test.must_contain(info_plist, 'PROCESSED_KEY1')
52  test.must_contain(info_plist, 'PROCESSED_KEY2')
53
54  test.pass_test()
55