37 output = os.path.join(ROOT_PATH, "temp/output_all") |
31 output = os.path.join(ROOT_PATH, "temp/output_all") |
38 self.recreate_dir(output) |
32 self.recreate_dir(output) |
39 |
33 |
40 prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"imageproject"))) |
34 prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"imageproject"))) |
41 config = prj.get_configuration('product.confml') |
35 config = prj.get_configuration('product.confml') |
42 implcontainer = plugin.get_impl_set(config, 'imageml$') |
36 context = plugin.GenerationContext(configuration=config, output=output) |
43 self.assertEquals(len(implcontainer), 4) |
37 context.filtering_disabled = True |
44 implcontainer.output = output |
38 |
45 implcontainer.generate() |
39 impl_set = plugin.get_impl_set(config, 'imageml$') |
|
40 self.assertEquals(len(impl_set), 5) |
|
41 impl_set.generate(context) |
46 |
42 |
47 def check_gen(p): |
43 def check_gen(p): |
48 self.assert_exists_and_contains_something(os.path.join(output, p)) |
44 self.assert_exists_and_contains_something(os.path.join(output, p)) |
49 def check_not_gen(p): |
45 def check_not_gen(p): |
50 self.assertFalse(os.path.exists(os.path.join(output, p)), "'%s' exists when it should not!" % p) |
46 self.assertFalse(os.path.exists(os.path.join(output, p)), "'%s' exists when it should not!" % p) |
51 |
47 |
52 try: |
48 try: |
53 check_gen('startup.mbm') |
49 check_gen('startup.mbm') |
54 check_gen('startup_mif.mif') |
50 check_gen('startup_mif.mif') |
55 |
51 |
56 check_not_gen('optional1_mbm.mbm') |
52 check_not_gen('optional1_mbm.mbm') |
57 check_gen('optional2_mbm.mbm') |
53 check_gen('optional2_mbm.mbm') |
58 check_not_gen('optional3_mbm.mbm') |
54 check_not_gen('optional3_mbm.mbm') |
59 check_not_gen('optional4_mbm.mbm') |
55 check_not_gen('optional4_mbm.mbm') |
60 |
56 |
61 check_not_gen('optional1_mif.mif') |
57 check_not_gen('optional1_mif.mif') |
62 check_gen('optional2_mif.mif') |
58 check_gen('optional2_mif.mif') |
63 check_not_gen('optional3_mif.mif') |
59 check_not_gen('optional3_mif.mif') |
64 check_not_gen('optional4_mif.mif') |
60 check_not_gen('optional4_mif.mif') |
65 |
61 |
66 check_gen('resource/apps/startup.mif') |
62 check_gen('resource/apps/startup.mif') |
67 |
63 |
68 check_gen('depth_from_ref_test_mbm.mbm') |
64 check_gen('depth_from_ref_test_mbm.mbm') |
69 check_gen('depth_from_ref_test_mif.mif') |
65 check_gen('depth_from_ref_test_mif.mif') |
70 except AssertionError: |
66 except AssertionError, e: |
71 if ' ' in ROOT_PATH: |
67 if ' ' in ROOT_PATH: |
72 self.fail("Known bug (#177)") |
68 self.fail("Known bug (#177): %s" % e) |
73 else: |
69 else: |
74 raise |
70 raise |
75 finally: |
71 finally: |
76 os.chdir(orig_workdir) |
72 os.chdir(orig_workdir) |
77 |
73 |
78 def _get_impl(self, filename): |
74 def _get_impl(self, filename): |
79 prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH, "imageproject"))) |
75 prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH, "imageproject"))) |
80 config = prj.get_configuration('product.confml') |
76 config = prj.get_configuration('product.confml') |
81 implcontainer = plugin.get_impl_set(config, re.escape(filename) + '$') |
77 implcontainer = plugin.get_impl_set(config, re.escape(filename) + '$') |
82 self.assertEquals(len(implcontainer), 1) |
78 self.assertEquals(len(implcontainer), 1) |
83 return iter(implcontainer).next() |
79 return iter(implcontainer).next() |
84 |
80 |
85 |
81 |
86 def test_get_refs(self): |
82 def test_get_refs(self): |
87 impl = self._get_impl('startupmif_animation.imageml') |
83 impl = self._get_impl('startupmif_animation.imageml') |
88 self.assertEquals(impl.get_refs(), None) |
84 self.assertEquals(impl.get_refs(), None) |
89 self.assertEquals(impl.has_ref('Foo.Bar'), None) |
85 self.assertEquals(impl.has_ref('Foo.Bar'), None) |
90 |
86 |
91 impl = self._get_impl('optional_test.imageml') |
87 impl = self._get_impl('optional_test.imageml') |
92 self.assertEquals(impl.get_refs(), ['OptionalTest.EmptyString', |
88 self.assertEquals(impl.get_refs(), ['OptionalTest.EmptyString', |
93 'OptionalTest.EmptyString2']) |
89 'OptionalTest.EmptyString2']) |
94 self.assertEquals(impl.has_ref('OptionalTest.EmptyString'), True) |
90 self.assertEquals(impl.has_ref('OptionalTest.EmptyString'), True) |
95 self.assertEquals(impl.has_ref('Foo.Foo'), False) |
91 self.assertEquals(impl.has_ref('Foo.Foo'), False) |
96 |
92 |
97 impl = self._get_impl('startup_animation.imageml') |
93 impl = self._get_impl('startup_animation.imageml') |
98 self.assertEquals(impl.get_refs(), ['CVC_StartupAnimationSequence.CVC_StartupFrameLocation.localPath']) |
94 self.assertEquals(impl.get_refs(), ['CVC_StartupAnimationSequence.CVC_StartupFrameLocation.localPath']) |
99 self.assertEquals(impl.has_ref('CVC_StartupAnimationSequence.CVC_StartupFrameLocation.localPath'), True) |
95 self.assertEquals(impl.has_ref('CVC_StartupAnimationSequence.CVC_StartupFrameLocation.localPath'), True) |
100 self.assertEquals(impl.has_ref('Foo.Foo'), False) |
96 self.assertEquals(impl.has_ref('Foo.Foo'), False) |
|
97 |
|
98 # Only run these tests on Windows |
|
99 if sys.platform != 'win32': |
|
100 del TestGeneratorFromProject |
101 |
101 |
102 if __name__ == '__main__': |
102 if __name__ == '__main__': |
103 unittest.main() |
103 unittest.main() |