|
| 1 | +/* |
| 2 | + * #%L |
| 3 | + * GwtMaterial |
| 4 | + * %% |
| 5 | + * Copyright (C) 2015 - 2017 GwtMaterialDesign |
| 6 | + * %% |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + * #L% |
| 19 | + */ |
| 20 | +package gwt.material.design.addins.client; |
| 21 | + |
| 22 | +import com.google.gwt.user.client.ui.RootPanel; |
| 23 | +import gwt.material.design.addins.client.base.MaterialAddinsTest; |
| 24 | +import gwt.material.design.addins.client.base.constants.AddinsCssName; |
| 25 | +import gwt.material.design.addins.client.emptystate.MaterialEmptyState; |
| 26 | +import gwt.material.design.client.constants.CssName; |
| 27 | +import gwt.material.design.client.constants.IconType; |
| 28 | +import gwt.material.design.client.ui.MaterialIcon; |
| 29 | +import gwt.material.design.client.ui.MaterialTitle; |
| 30 | +import gwt.material.design.client.ui.html.Div; |
| 31 | + |
| 32 | +public class MaterialEmptyStateTest extends MaterialAddinsTest { |
| 33 | + |
| 34 | + public void init() { |
| 35 | + MaterialEmptyState emptyState = new MaterialEmptyState(); |
| 36 | + checkWidget(emptyState); |
| 37 | + checkStructure(emptyState); |
| 38 | + checkLoading(emptyState); |
| 39 | + } |
| 40 | + |
| 41 | + protected void checkStructure(MaterialEmptyState emptyState) { |
| 42 | + final String TITLE = "title"; |
| 43 | + final String DESCRIPTION = "description"; |
| 44 | + final IconType ICON = IconType.POLL; |
| 45 | + |
| 46 | + emptyState.setTitle(TITLE); |
| 47 | + emptyState.setDescription(DESCRIPTION); |
| 48 | + emptyState.setIconType(ICON); |
| 49 | + RootPanel.get().add(emptyState); |
| 50 | + |
| 51 | + assertTrue(emptyState.getElement().hasClassName(AddinsCssName.EMPTY_STATE)); |
| 52 | + assertTrue(emptyState.getElement().hasClassName(CssName.VALIGN_WRAPPER)); |
| 53 | + |
| 54 | + assertEquals(emptyState.getWidgetCount(), 1); |
| 55 | + assertEquals(emptyState.getWidget(0), emptyState.getContainer()); |
| 56 | + |
| 57 | + Div container = emptyState.getContainer(); |
| 58 | + assertEquals(container.getWidgetCount(), 1); |
| 59 | + assertTrue(container.getElement().hasClassName(CssName.VALIGN)); |
| 60 | + assertTrue(container.getElement().hasClassName(CssName.CENTER)); |
| 61 | + |
| 62 | + assertTrue(container.getWidget(0) instanceof MaterialTitle); |
| 63 | + MaterialTitle title = (MaterialTitle) container.getWidget(0); |
| 64 | + |
| 65 | + assertEquals(title.getHeader().getText(), TITLE); |
| 66 | + assertEquals(title.getParagraph().getText(), DESCRIPTION); |
| 67 | + |
| 68 | + assertTrue(title.getWidget(0) instanceof MaterialIcon); |
| 69 | + MaterialIcon icon = (MaterialIcon) title.getWidget(0); |
| 70 | + assertEquals(icon.getIconType(), ICON); |
| 71 | + } |
| 72 | + |
| 73 | + public void checkLoading(MaterialEmptyState emptyState) { |
| 74 | + emptyState.setLoading(true); |
| 75 | + assertTrue(emptyState.isLoading()); |
| 76 | + emptyState.setLoading(false); |
| 77 | + assertFalse(emptyState.isLoading()); |
| 78 | + } |
| 79 | +} |
0 commit comments