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 static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21 import static org.mockito.Mockito.doReturn;
22 import static org.mockito.Mockito.spy;
23
24 import java.util.HashMap;
25
26 import org.junit.Test;
27 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
28 import org.kuali.rice.krad.test.KRADTestCase;
29 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
30 import org.kuali.rice.krad.web.form.UifFormBase;
31 import org.springframework.mock.web.MockHttpServletRequest;
32 import org.springframework.mock.web.MockHttpServletResponse;
33
34
35
36
37
38
39 public class ViewThemeTest extends KRADTestCase {
40
41
42
43
44
45 @Test
46 public void testManualThemeConfiguration() {
47 MockHttpServletRequest request = new MockHttpServletRequest();
48 MockHttpServletResponse response = new MockHttpServletResponse();
49
50 View view = KRADServiceLocatorWeb.getViewService().getViewById("TestViewTheme1");
51
52 ViewTheme theme = view.getTheme();
53 assertNotNull(theme);
54
55 assertEquals(2, theme.getMinCssSourceFiles().size());
56 assertEquals(2, theme.getMinScriptSourceFiles().size());
57
58
59 theme = spy(theme);
60 doReturn(true).when(theme).inDevMode();
61 view.setTheme(theme);
62
63 ViewLifecycle.buildView(view, new UifFormBase(), request, new HashMap<String, String>());
64
65 assertEquals(2, theme.getCssFiles().size());
66 assertEquals(2, theme.getScriptFiles().size());
67
68
69 view = KRADServiceLocatorWeb.getViewService().getViewById("TestViewTheme1");
70
71 theme = view.getTheme();
72 assertNotNull(theme);
73
74 theme = spy(theme);
75 doReturn(false).when(theme).inDevMode();
76 view.setTheme(theme);
77
78 ViewLifecycle.buildView(view, new UifFormBase(), request, new HashMap<String, String>());
79
80 assertEquals(1, theme.getCssFiles().size());
81 assertEquals(1, theme.getScriptFiles().size());
82
83 assertTrue(theme.getCssFiles().contains(theme.getMinCssFile()));
84 assertTrue(theme.getScriptFiles().contains(theme.getMinScriptFile()));
85 }
86 }