Skip to content

Commit f5d8338

Browse files
committed
Add JUnit Test for MaterialEmptyState
1 parent 1701d8b commit f5d8338

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

src/main/java/gwt/material/design/addins/client/emptystate/MaterialEmptyState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,6 @@ public boolean isLoading() {
153153

154154
public void setLoading(boolean loading) {
155155
this.loading = loading;
156-
MaterialLoader.showLoading(true, icon);
156+
MaterialLoader.showLoading(loading, icon);
157157
}
158158
}

src/test/java/gwt/material/design/addins/client/GwtMaterialAddinsTestComponent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ public void testDocViewer() {
8484
new MaterialDocViewerTest().init();
8585
}
8686

87+
public void testEmptyState() {
88+
new MaterialEmptyStateTest().init();
89+
}
90+
8791
public void testFileUploader() {
8892
new MaterialFileUploaderTest().init();
8993
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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

Comments
 (0)