• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
18import {
19  ComponentFixture,
20  ComponentFixtureAutoDetect,
21  TestBed,
22} from '@angular/core/testing';
23import {FormsModule} from '@angular/forms';
24import {MatButtonModule} from '@angular/material/button';
25import {MatDividerModule} from '@angular/material/divider';
26import {MatIconModule} from '@angular/material/icon';
27import {MatTooltipModule} from '@angular/material/tooltip';
28import {UnitTestUtils} from 'test/unit/utils';
29import {CollapsedSectionsComponent} from './collapsed_sections_component';
30import {CollapsibleSectionTitleComponent} from './collapsible_section_title_component';
31import {HierarchyComponent} from './hierarchy_component';
32import {ImeAdditionalPropertiesComponent} from './ime_additional_properties_component';
33import {PropertiesComponent} from './properties_component';
34import {ViewerInputMethodComponent} from './viewer_input_method_component';
35
36describe('ViewerInputMethodComponent', () => {
37  let fixture: ComponentFixture<ViewerInputMethodComponent>;
38  let component: ViewerInputMethodComponent;
39  let htmlElement: HTMLElement;
40
41  beforeEach(async () => {
42    await TestBed.configureTestingModule({
43      providers: [{provide: ComponentFixtureAutoDetect, useValue: true}],
44      imports: [
45        MatIconModule,
46        MatDividerModule,
47        MatButtonModule,
48        MatTooltipModule,
49        FormsModule,
50      ],
51      declarations: [
52        ViewerInputMethodComponent,
53        HierarchyComponent,
54        PropertiesComponent,
55        ImeAdditionalPropertiesComponent,
56        CollapsedSectionsComponent,
57        CollapsibleSectionTitleComponent,
58      ],
59      schemas: [CUSTOM_ELEMENTS_SCHEMA],
60    }).compileComponents();
61    fixture = TestBed.createComponent(ViewerInputMethodComponent);
62    component = fixture.componentInstance;
63    htmlElement = fixture.nativeElement;
64    fixture.detectChanges();
65  });
66
67  it('can be created', () => {
68    expect(component).toBeTruthy();
69  });
70
71  it('creates hierarchy view', () => {
72    const hierarchyView = htmlElement.querySelector('.hierarchy-view');
73    expect(hierarchyView).toBeTruthy();
74  });
75
76  it('creates additional properties view', () => {
77    const additionalProperties = htmlElement.querySelector(
78      '.ime-additional-properties',
79    );
80    expect(additionalProperties).toBeTruthy();
81  });
82
83  it('creates properties view', () => {
84    const propertiesView = htmlElement.querySelector('.properties-view');
85    expect(propertiesView).toBeTruthy();
86  });
87
88  it('creates collapsed sections with no buttons', () => {
89    UnitTestUtils.checkNoCollapsedSectionButtons(htmlElement);
90  });
91
92  it('handles hierarchy section collapse/expand', () => {
93    UnitTestUtils.checkSectionCollapseAndExpand(
94      htmlElement,
95      fixture,
96      '.hierarchy-view',
97      'HIERARCHY',
98    );
99  });
100
101  it('handles ime additional properties section collapse/expand', () => {
102    UnitTestUtils.checkSectionCollapseAndExpand(
103      htmlElement,
104      fixture,
105      '.ime-additional-properties',
106      'WM & SF PROPERTIES',
107    );
108  });
109
110  it('handles properties section collapse/expand', () => {
111    UnitTestUtils.checkSectionCollapseAndExpand(
112      htmlElement,
113      fixture,
114      '.properties-view',
115      'PROPERTIES',
116    );
117  });
118});
119