1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.view;
17
18 import org.junit.Test;
19 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
20 import org.kuali.rice.krad.test.KRADTestCase;
21 import org.kuali.rice.krad.web.form.UifFormBase;
22
23 import java.util.HashMap;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28 import static org.mockito.Mockito.doReturn;
29 import static org.mockito.Mockito.spy;
30
31
32
33
34
35
36 public class ViewThemeTest extends KRADTestCase {
37
38
39
40
41
42 @Test
43 public void testManualThemeConfiguration() {
44 View view = KRADServiceLocatorWeb.getViewService().getViewById("TestViewTheme1");
45
46 ViewTheme theme = view.getTheme();
47 assertNotNull(theme);
48
49 assertEquals(2, theme.getMinCssSourceFiles().size());
50 assertEquals(2, theme.getMinScriptSourceFiles().size());
51
52
53 theme = spy(theme);
54 doReturn(true).when(theme).inDevMode();
55 view.setTheme(theme);
56
57 KRADServiceLocatorWeb.getViewService().buildView(view, new UifFormBase(), new HashMap<String, String>());
58
59 assertEquals(2, theme.getCssFiles().size());
60 assertEquals(2, theme.getScriptFiles().size());
61
62
63 view = KRADServiceLocatorWeb.getViewService().getViewById("TestViewTheme1");
64
65 theme = view.getTheme();
66 assertNotNull(theme);
67
68 theme = spy(theme);
69 doReturn(false).when(theme).inDevMode();
70 view.setTheme(theme);
71
72 KRADServiceLocatorWeb.getViewService().buildView(view, new UifFormBase(), new HashMap<String, String>());
73
74 assertEquals(1, theme.getCssFiles().size());
75 assertEquals(1, theme.getScriptFiles().size());
76
77 assertTrue(theme.getCssFiles().contains(theme.getMinCssFile()));
78 assertTrue(theme.getScriptFiles().contains(theme.getMinScriptFile()));
79 }
80 }