@@ -62,6 +62,7 @@ describe('MdInputContainer without forms', function () {
6262 MdTextareaWithBindings ,
6363 MdInputContainerWithNgIf ,
6464 MdInputContainerOnPush ,
65+ MdInputContainerWithReadonlyInput ,
6566 ] ,
6667 } ) ;
6768
@@ -604,6 +605,39 @@ describe('MdInputContainer without forms', function () {
604605
605606 expect ( placeholder . classList ) . not . toContain ( 'mat-empty' , 'Input no longer empty' ) ;
606607 } ) ;
608+
609+ it ( 'should set the focused class when the input is focused' , ( ) => {
610+ let fixture = TestBed . createComponent ( MdInputContainerTextTestController ) ;
611+ fixture . detectChanges ( ) ;
612+
613+ let input = fixture . debugElement . query ( By . directive ( MdInputDirective ) )
614+ . injector . get < MdInputDirective > ( MdInputDirective ) ;
615+ let container = fixture . debugElement . query ( By . css ( 'md-input-container' ) ) . nativeElement ;
616+
617+ // Call the focus handler directly to avoid flakyness where
618+ // browsers don't focus elements if the window is minimized.
619+ input . _onFocus ( ) ;
620+ fixture . detectChanges ( ) ;
621+
622+ expect ( container . classList ) . toContain ( 'mat-focused' ) ;
623+ } ) ;
624+
625+ it ( 'should not highlight when focusing a readonly input' , ( ) => {
626+ let fixture = TestBed . createComponent ( MdInputContainerWithReadonlyInput ) ;
627+ fixture . detectChanges ( ) ;
628+
629+ let input = fixture . debugElement . query ( By . directive ( MdInputDirective ) )
630+ . injector . get < MdInputDirective > ( MdInputDirective ) ;
631+ let container = fixture . debugElement . query ( By . css ( 'md-input-container' ) ) . nativeElement ;
632+
633+ // Call the focus handler directly to avoid flakyness where
634+ // browsers don't focus elements if the window is minimized.
635+ input . _onFocus ( ) ;
636+ fixture . detectChanges ( ) ;
637+
638+ expect ( input . focused ) . toBe ( false ) ;
639+ expect ( container . classList ) . not . toContain ( 'mat-focused' ) ;
640+ } ) ;
607641} ) ;
608642
609643describe ( 'MdInputContainer with forms' , ( ) => {
@@ -1230,3 +1264,12 @@ class MdInputContainerWithNgIf {
12301264class MdInputContainerOnPush {
12311265 formControl = new FormControl ( '' ) ;
12321266}
1267+
1268+ @Component ( {
1269+ template : `
1270+ <md-input-container>
1271+ <input mdInput readonly value="Only for reading">
1272+ </md-input-container>
1273+ `
1274+ } )
1275+ class MdInputContainerWithReadonlyInput { }
0 commit comments