blob: 5cfe9806750973e02581a74abd18630c42bbdc0b [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001# Copyright 2015 The Bazel Authors. All rights reserved.
Alex Humeskya4ecde62015-05-21 17:08:42 +00002#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Unit tests for stubify_application_manifest."""
16
17import unittest
18from xml.etree import ElementTree
19
20from tools.android.build_split_manifest import BuildSplitManifest
21
22
23MAIN_MANIFEST = """
24<manifest
25 xmlns:android="http://schemas.android.com/apk/res/android"
26 package="com.google.package"
27 android:versionCode="1"
28 android:versionName="1.0">
29</manifest>
30"""
31
32
33class BuildSplitManifestTest(unittest.TestCase):
34
35 def testNoPackageOveride(self):
36 split = BuildSplitManifest(MAIN_MANIFEST, None, "split", False)
37 manifest = ElementTree.fromstring(split)
38 self.assertEqual("com.google.package",
39 manifest.get("package"))
40
41 def testPackageOveride(self):
42 split = BuildSplitManifest(MAIN_MANIFEST, "package.other", "split", False)
43 manifest = ElementTree.fromstring(split)
44 self.assertEqual("package.other",
45 manifest.get("package"))
46
47 def testSplitName(self):
48 split = BuildSplitManifest(MAIN_MANIFEST, None, "my.little.splony", False)
49 manifest = ElementTree.fromstring(split)
50 self.assertEqual("my.little.splony", manifest.get("split"))
51
52
53if __name__ == "__main__":
54 unittest.main()