inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType,
       new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}),
       '<style>a</style>', 'package:some/module/');
   expect(template.styles).toEqual(['a']);
 }));
 (async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: SpyXHR) => {
   programXhrSpy(xhr, {
     'package:some/module/test.css': 'a@import "test2.css"',
     'package:some/module/test2.css': 'b'
   });
   normalizer
       .normalizeExternalStylesheets(new CompileTemplateMetadata({
         template: '',
         templateUrl: '',
         styleUrls: ['package:some/module/test.css']
       }))
       .then((template: CompileTemplateMetadata) => {
         expect(template.externalStylesheets.length).toBe(2);
         expect(template.externalStylesheets[0]).toEqual(new CompileStylesheetMetadata({
           moduleUrl: 'package:some/module/test.css',
           styles: ['a'],
           styleUrls: ['package:some/module/test2.css']
         }));
         expect(template.externalStylesheets[1]).toEqual(new CompileStylesheetMetadata({
           moduleUrl: 'package:some/module/test2.css',
           styles: ['b'],
           styleUrls: []
         }));
         async.done();
       });
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType,
       new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}),
       '<ng-content select="a"></ng-content>', 'package:some/module/');
   expect(template.ngContentSelectors).toEqual(['a']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType,
       new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}),
       '<div ngNonBindable><style>div {color:red}</style></div>', 'package:some/module/');
   expect(template.styles).toEqual(['div {color:red}']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType, new CompileTemplateMetadata(
                    {encapsulation: ViewEncapsulation.Emulated, styles: [], styleUrls: []}),
       '', 'package:some/module/id');
   expect(template.encapsulation).toEqual(ViewEncapsulation.None);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType,
       new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}),
       '<link href="http://some/external.css" rel="stylesheet">', 'package:some/module/');
   expect(template.styleUrls).toEqual([]);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType,
       new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}),
       '<div><link rel="stylesheet" href="aUrl"></div>', 'package:some/module/');
   expect(template.styleUrls).toEqual(['package:some/module/aUrl']);
 }));
 (async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
   xhr.expect('package:some/module/cmp.html', 'a');
   var templateMeta = new CompileTemplateMetadata({
     templateUrl: 'cmp.html',
   });
   Promise
       .all([
         normalizer.normalizeTemplateAsync(dirType, templateMeta),
         normalizer.normalizeTemplateAsync(dirType, templateMeta)
       ])
       .then((templates: CompileTemplateMetadata[]) => {
         expect(templates[0].template).toEqual('a');
         expect(templates[1].template).toEqual('a');
         async.done();
       });
   xhr.flush();
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType, new CompileTemplateMetadata(
                    {encapsulation: null, styles: ['@import "test.css";'], styleUrls: []}),
       '', 'package:some/module/id');
   expect(template.styles).toEqual(['']);
   expect(template.styleUrls).toEqual(['package:some/module/test.css']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirTypeWithHttpUrl, new CompileTemplateMetadata(
                               {encapsulation: null, styles: [], styleUrls: ['test.css']}),
       '', 'http://some/module/id');
   expect(template.styles).toEqual([]);
   expect(template.styleUrls).toEqual(['http://some/module/test.css']);
 }));
         inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {

           var viewEncapsulation = ViewEncapsulation.Native;
           var template = normalizer.normalizeLoadedTemplate(
               dirType, new CompileTemplateMetadata(
                            {encapsulation: viewEncapsulation, styles: [], styleUrls: []}),
               '', 'package:some/module/');
           expect(template.encapsulation).toBe(viewEncapsulation);
         }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   let template = normalizer.normalizeTemplateSync(dirType, new CompileTemplateMetadata({
                                                     encapsulation: null,
                                                     template: '',
                                                     templateUrl: null,
                                                     styles: [],
                                                     styleUrls: ['test.css']
                                                   }))
   expect(template.encapsulation).toEqual(ViewEncapsulation.Emulated);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
                                                       encapsulation: null,
                                                       styles: [],
                                                       styleUrls: [],
                                                       baseUrl: 'package:some/module/a.js'
                                                     }),
                                                     'a', 'package:some/module/');
   expect(template.template).toEqual('a')
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   let template = normalizer.normalizeTemplateSync(dirType, new CompileTemplateMetadata({
                                                     encapsulation: null,
                                                     template: '',
                                                     templateUrl: null,
                                                     styles: [],
                                                     styleUrls: ['test.css']
                                                   }))
   expect(template.styleUrls).toEqual(['package:some/module/test.css']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   var template = normalizer.normalizeLoadedTemplate(
       dirType, new CompileTemplateMetadata({
         encapsulation: null,
         styles: ['.foo{background-image: url(\'double.jpg\');'],
         styleUrls: []
       }),
       '', 'package:some/module/id');
   expect(template.styles).toEqual(['.foo{background-image: url(\'double.jpg\');']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   let template = normalizer.normalizeTemplateSync(dirType, new CompileTemplateMetadata({
                                                     encapsulation: null,
                                                     template: 'a',
                                                     templateUrl: null,
                                                     styles: [],
                                                     styleUrls: []
                                                   }))
   expect(template.template).toEqual('a');
   expect(template.templateUrl).toEqual('package:some/module/a.js');
 }));
 (async: AsyncTestCompleter, normalizer: DirectiveNormalizer,
  resourceLoader: MockResourceLoader) => {
   resourceLoader.expect('package:some/module/cmp.html', 'a');
   const prenormMeta = {
     componentType: SomeComp,
     moduleUrl: SOME_MODULE_URL,
     templateUrl: 'cmp.html',
   };
   Promise
       .all([
         normalizer.normalizeTemplateAsync(prenormMeta),
         normalizer.normalizeTemplateAsync(prenormMeta)
       ])
       .then((templates: CompileTemplateMetadata[]) => {
         expect(templates[0].template).toEqual('a');
         expect(templates[1].template).toEqual('a');
         async.done();
       });
   resourceLoader.flush();
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: [],
         styleUrls: []
       },
       'a', 'package:some/module/');
   expect(template.template).toEqual('a');
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: [],
         styleUrls: []
       },
       '<ng-content select="a"></ng-content>', 'package:some/module/');
   expect(template.ngContentSelectors).toEqual(['a']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: [],
         styleUrls: []
       },
       '<div><link rel="stylesheet" href="aUrl"></div>', 'package:some/module/');
   expect(template.styleUrls).toEqual(['package:some/module/aUrl']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: ['.foo{background-image: url(\'double.jpg\');'],
         styleUrls: []
       },
       '', 'package:some/module/id');
   expect(template.styles).toEqual(['.foo{background-image: url(\'double.jpg\');']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeTemplateSync({
     componentType: SomeComp,
     moduleUrl: SOME_MODULE_URL,
     encapsulation: null,
     template: '',
     templateUrl: null,
     styles: [],
     styleUrls: ['test.css']
   });
   expect(template.encapsulation).toEqual(ViewEncapsulation.Emulated);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeTemplateSync({
     componentType: SomeComp,
     moduleUrl: SOME_MODULE_URL,
     encapsulation: null,
     template: '<style>@import test.css</style>',
     templateUrl: null,
     styles: [],
     styleUrls: []
   });
   expect(template.styleUrls).toEqual(['package:some/module/test.css']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: [],
         styleUrls: []
       },
       '<div ngNonBindable><style>div {color:red}</style></div>', 'package:some/module/');
   expect(template.styles).toEqual(['div {color:red}']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: ViewEncapsulation.Emulated,
         styles: [],
         styleUrls: []
       },
       '', 'package:some/module/id');
   expect(template.encapsulation).toEqual(ViewEncapsulation.None);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: [],
         styleUrls: []
       },
       '<link href="http://some/external.css" rel="stylesheet">', 'package:some/module/');
   expect(template.styleUrls).toEqual([]);
 }));
 (config: CompilerConfig, normalizer: DirectiveNormalizer) => {
   config.defaultEncapsulation = ViewEncapsulation.None;
   let template =
       normalizer.normalizeTemplateSync(dirType, new CompileTemplateMetadata({
                                          encapsulation: null,
                                          template: '',
                                          templateUrl: null,
                                          styles: [],
                                          styleUrls: ['test.css']
                                        }))
   expect(template.encapsulation).toEqual(ViewEncapsulation.None);
 }));
 (config: CompilerConfig, normalizer: DirectiveNormalizer) => {
   config.defaultEncapsulation = ViewEncapsulation.None;
   const template = normalizer.normalizeTemplateSync({
     componentType: SomeComp,
     moduleUrl: SOME_MODULE_URL,
     encapsulation: null,
     template: '',
     templateUrl: null,
     styles: [],
     styleUrls: ['test.css']
   });
   expect(template.encapsulation).toEqual(ViewEncapsulation.None);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_HTTP_MODULE_URL,
         encapsulation: null,
         styles: [],
         styleUrls: ['test.css']
       },
       '', 'http://some/module/id');
   expect(template.styles).toEqual([]);
   expect(template.styleUrls).toEqual(['http://some/module/test.css']);
 }));
 inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
   const template = normalizer.normalizeLoadedTemplate(
       {
         componentType: SomeComp,
         moduleUrl: SOME_MODULE_URL,
         encapsulation: null,
         styles: ['@import "test.css";'],
         styleUrls: []
       },
       '', 'package:some/module/id');
   expect(template.styles).toEqual(['']);
   expect(template.styleUrls).toEqual(['package:some/module/test.css']);
 }));