@@ -194,6 +194,49 @@ describe('MdSidenav', () => {
194194 tick ( ) ;
195195 } ) . not . toThrow ( ) ;
196196 } ) ) ;
197+
198+ it ( 'should emit the backdrop-clicked event when the backdrop is clicked' , fakeAsync ( ( ) => {
199+ let fixture = TestBed . createComponent ( BasicTestApp ) ;
200+
201+ let testComponent : BasicTestApp = fixture . debugElement . componentInstance ;
202+ let openButtonElement = fixture . debugElement . query ( By . css ( '.open' ) ) ;
203+ openButtonElement . nativeElement . click ( ) ;
204+ fixture . detectChanges ( ) ;
205+ tick ( ) ;
206+
207+ endSidenavTransition ( fixture ) ;
208+ tick ( ) ;
209+
210+ expect ( testComponent . backdropClickedCount ) . toBe ( 0 ) ;
211+
212+ let sidenavBackdropElement = fixture . debugElement . query ( By . css ( '.md-sidenav-backdrop' ) ) ;
213+ sidenavBackdropElement . nativeElement . click ( ) ;
214+ fixture . detectChanges ( ) ;
215+ tick ( ) ;
216+
217+ expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
218+
219+ endSidenavTransition ( fixture ) ;
220+ tick ( ) ;
221+
222+ openButtonElement . nativeElement . click ( ) ;
223+ fixture . detectChanges ( ) ;
224+ tick ( ) ;
225+
226+ endSidenavTransition ( fixture ) ;
227+ tick ( ) ;
228+
229+ let closeButtonElement = fixture . debugElement . query ( By . css ( '.close' ) ) ;
230+ closeButtonElement . nativeElement . click ( ) ;
231+ fixture . detectChanges ( ) ;
232+ tick ( ) ;
233+
234+ endSidenavTransition ( fixture ) ;
235+ tick ( ) ;
236+
237+ expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
238+ } ) ) ;
239+
197240 } ) ;
198241
199242 describe ( 'attributes' , ( ) => {
@@ -271,7 +314,7 @@ class SidenavLayoutTwoSidenavTestApp { }
271314/** Test component that contains an MdSidenavLayout and one MdSidenav. */
272315@Component ( {
273316 template : `
274- <md-sidenav-layout>
317+ <md-sidenav-layout (backdrop-clicked)="backdropClicked()" >
275318 <md-sidenav #sidenav align="start"
276319 (open-start)="openStart()"
277320 (open)="open()"
@@ -288,6 +331,7 @@ class BasicTestApp {
288331 openCount : number = 0 ;
289332 closeStartCount : number = 0 ;
290333 closeCount : number = 0 ;
334+ backdropClickedCount : number = 0 ;
291335
292336 openStart ( ) {
293337 this . openStartCount ++ ;
@@ -304,6 +348,10 @@ class BasicTestApp {
304348 close ( ) {
305349 this . closeCount ++ ;
306350 }
351+
352+ backdropClicked ( ) {
353+ this . backdropClickedCount ++ ;
354+ }
307355}
308356
309357@Component ( {
0 commit comments