@@ -190,6 +190,49 @@ describe('MdSidenav', () => {
190190 tick ( ) ;
191191 } ) . not . toThrow ( ) ;
192192 } ) ) ;
193+
194+ it ( 'should emit the backdrop-clicked event when the backdrop is clicked' , fakeAsync ( ( ) => {
195+ let fixture = TestBed . createComponent ( BasicTestApp ) ;
196+
197+ let testComponent : BasicTestApp = fixture . debugElement . componentInstance ;
198+ let openButtonElement = fixture . debugElement . query ( By . css ( '.open' ) ) ;
199+ openButtonElement . nativeElement . click ( ) ;
200+ fixture . detectChanges ( ) ;
201+ tick ( ) ;
202+
203+ endSidenavTransition ( fixture ) ;
204+ tick ( ) ;
205+
206+ expect ( testComponent . backdropClickedCount ) . toBe ( 0 ) ;
207+
208+ let sidenavBackdropElement = fixture . debugElement . query ( By . css ( '.md-sidenav-backdrop' ) ) ;
209+ sidenavBackdropElement . nativeElement . click ( ) ;
210+ fixture . detectChanges ( ) ;
211+ tick ( ) ;
212+
213+ expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
214+
215+ endSidenavTransition ( fixture ) ;
216+ tick ( ) ;
217+
218+ openButtonElement . nativeElement . click ( ) ;
219+ fixture . detectChanges ( ) ;
220+ tick ( ) ;
221+
222+ endSidenavTransition ( fixture ) ;
223+ tick ( ) ;
224+
225+ let closeButtonElement = fixture . debugElement . query ( By . css ( '.close' ) ) ;
226+ closeButtonElement . nativeElement . click ( ) ;
227+ fixture . detectChanges ( ) ;
228+ tick ( ) ;
229+
230+ endSidenavTransition ( fixture ) ;
231+ tick ( ) ;
232+
233+ expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
234+ } ) ) ;
235+
193236 } ) ;
194237
195238 describe ( 'attributes' , ( ) => {
@@ -267,7 +310,7 @@ class SidenavLayoutTwoSidenavTestApp { }
267310/** Test component that contains an MdSidenavLayout and one MdSidenav. */
268311@Component ( {
269312 template : `
270- <md-sidenav-layout>
313+ <md-sidenav-layout (backdrop-clicked)="backdropClicked()" >
271314 <md-sidenav #sidenav align="start"
272315 (open-start)="openStart()"
273316 (open)="open()"
@@ -284,6 +327,7 @@ class BasicTestApp {
284327 openCount : number = 0 ;
285328 closeStartCount : number = 0 ;
286329 closeCount : number = 0 ;
330+ backdropClickedCount : number = 0 ;
287331
288332 openStart ( ) {
289333 this . openStartCount ++ ;
@@ -300,6 +344,10 @@ class BasicTestApp {
300344 close ( ) {
301345 this . closeCount ++ ;
302346 }
347+
348+ backdropClicked ( ) {
349+ this . backdropClickedCount ++ ;
350+ }
303351}
304352
305353@Component ( {
0 commit comments