コード例 #1
0
    def testInlineStylesheetURLs(self):
        file_contents = {}
        file_contents['/tmp/a/b/my_component.html'] = """
<!DOCTYPE html>
<style>
.some-rule {
    background-image: url('../something.jpg');
}
</style>
"""
        file_contents['/tmp/a/something.jpg'] = 'jpgdata'
        with fake_fs.FakeFS(file_contents):
            project = project_module.Project(['/tvcm/', '/tmp/'],
                                             include_tvcm_paths=False)
            loader = resource_loader.ResourceLoader(project)
            my_component = loader.LoadModule(module_name='a.b.my_component')

            computed_deps = []
            my_component.AppendDirectlyDependentFilenamesTo(computed_deps)
            self.assertEquals(
                set(computed_deps),
                set(['/tmp/a/b/my_component.html', '/tmp/a/something.jpg']))

            f = StringIO.StringIO()
            ctl = html_generation_controller.HTMLGenerationController()
            my_component.AppendHTMLContentsToFile(f, ctl)
            html = f.getvalue().rstrip()
            expected_html = """
.some-rule {
    background-image: url(data:image/jpg;base64,anBnZGF0YQ==);
}
""".rstrip()
            print html
コード例 #2
0
 def html_contents_without_links_and_script(self):
   return self.GenerateHTML(html_generation_controller.HTMLGenerationController())