@@ -617,6 +617,27 @@ describe('MDC-based MatMenu', () => {
617617    expect ( items . every ( item  =>  item . getAttribute ( 'role' )  ===  'menuitemcheckbox' ) ) . toBe ( true ) ; 
618618  } ) ; 
619619
620+   it ( 'should not change focus origin if origin not specified for menu items' ,  ( )  =>  { 
621+     const  fixture  =  createComponent ( MenuWithCheckboxItems ) ; 
622+     fixture . detectChanges ( ) ; 
623+     fixture . componentInstance . trigger . openMenu ( ) ; 
624+     fixture . detectChanges ( ) ; 
625+ 
626+     let  [ firstMenuItemDebugEl ,  secondMenuItemDebugEl ]  = 
627+            fixture . debugElement . queryAll ( By . css ( '.mat-mdc-menu-item' ) ) ! ; 
628+ 
629+     const  firstMenuItemInstance  =  firstMenuItemDebugEl . componentInstance  as  MatMenuItem ; 
630+     const  secondMenuItemInstance  =  secondMenuItemDebugEl . componentInstance  as  MatMenuItem ; 
631+ 
632+     firstMenuItemDebugEl . nativeElement . blur ( ) ; 
633+     firstMenuItemInstance . focus ( 'mouse' ) ; 
634+     secondMenuItemDebugEl . nativeElement . blur ( ) ; 
635+     secondMenuItemInstance . focus ( ) ; 
636+ 
637+     expect ( secondMenuItemDebugEl . nativeElement . classList ) . toContain ( 'cdk-focused' ) ; 
638+     expect ( secondMenuItemDebugEl . nativeElement . classList ) . toContain ( 'cdk-mouse-focused' ) ; 
639+   } ) ; 
640+ 
620641  it ( 'should not throw an error on destroy' ,  ( )  =>  { 
621642    const  fixture  =  createComponent ( SimpleMenu ,  [ ] ,  [ FakeIcon ] ) ; 
622643    expect ( fixture . destroy . bind ( fixture ) ) . not . toThrow ( ) ; 
@@ -2028,6 +2049,23 @@ describe('MDC-based MatMenu', () => {
20282049            . toContain ( 'mat-elevation-z4' ,  'Expected menu to have the proper updated elevation.' ) ; 
20292050      } ) ) ; 
20302051
2052+     it ( 'should not change focus origin if origin not specified for trigger' ,  fakeAsync ( ( )  =>  { 
2053+       compileTestComponent ( ) ; 
2054+ 
2055+       instance . levelOneTrigger . openMenu ( ) ; 
2056+       instance . levelOneTrigger . focus ( 'mouse' ) ; 
2057+       fixture . detectChanges ( ) ; 
2058+ 
2059+       instance . levelTwoTrigger . focus ( ) ; 
2060+       fixture . detectChanges ( ) ; 
2061+       tick ( 500 ) ; 
2062+ 
2063+       const  levelTwoTrigger  =  overlay . querySelector ( '#level-two-trigger' ) !  as  HTMLElement ; 
2064+ 
2065+       expect ( levelTwoTrigger . classList ) . toContain ( 'cdk-focused' ) ; 
2066+       expect ( levelTwoTrigger . classList ) . toContain ( 'cdk-mouse-focused' ) ; 
2067+     } ) ) ; 
2068+ 
20312069    // TODO(crisbeto): disabled until we've mapped our elevation to MDC's. 
20322070    // tslint:disable-next-line:ban 
20332071    xit ( 'should not increase the elevation if the user specified a custom one' ,  ( )  =>  { 
0 commit comments