1 /*
2 * *************************************************************************************************************************************************************
3 *
4 * SteelBlue: DCI User Interfaces
5 * http://tidalwave.it/projects/steelblue
6 *
7 * Copyright (C) 2015 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8 *
9 * *************************************************************************************************************************************************************
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18 *
19 * *************************************************************************************************************************************************************
20 *
21 * git clone https://bitbucket.org/tidalwave/steelblue-src
22 * git clone https://github.com/tidalwave-it/steelblue-src
23 *
24 * *************************************************************************************************************************************************************
25 */
26 package it.tidalwave.ui.core;
27
28 import jakarta.annotation.Nonnull;
29 import java.util.List;
30 import java.util.Map;
31 import org.testng.annotations.Test;
32 import static it.tidalwave.ui.core.PanelGroupControl.Options.*;
33 import static it.tidalwave.ui.core.PanelGroupControl.DefaultGroups.*;
34 import static org.mockito.Mockito.*;
35 import static org.hamcrest.CoreMatchers.is;
36 import static org.hamcrest.MatcherAssert.assertThat;
37
38 /***************************************************************************************************************************************************************
39 *
40 * @author Fabrizio Giudici
41 *
42 **************************************************************************************************************************************************************/
43 public class PanelGroupControlTest
44 {
45 static class Fixture implements PanelGroupControl<MockPanel>
46 {
47 @Override
48 public void setup (@Nonnull final Configuration<MockPanel> configuration)
49 {
50 // not needed in tests
51 }
52
53 @Override
54 public void show (@Nonnull final Object object)
55 {
56 // not needed in tests
57 }
58 }
59
60 static class MockPanel {}
61
62 @Test
63 public void test_Configuration()
64 {
65 // given
66 final var panelLeft = mock(MockPanel.class);
67 final var panelCenter = mock(MockPanel.class);
68 final var panelBottom = mock(MockPanel.class);
69 final var panelRight = mock(MockPanel.class);
70 final var f = new Fixture(); // needed only for calling config()
71 // when
72 final var underTest = f.config()
73 .withGroup(LEFT, panelLeft, ALWAYS_WRAP)
74 .withGroup(CENTER, panelCenter, ALWAYS_WRAP)
75 .withGroup(BOTTOM, panelBottom, ALWAYS_WRAP)
76 .withGroup(RIGHT, panelRight, ALWAYS_WRAP)
77 .withOptions(DISABLE_ACCORDION_ANIMATION);
78 // then
79 assertThat(underTest.getTopContainersByGroup(), is(Map.of(LEFT, panelLeft,
80 CENTER, panelCenter,
81 BOTTOM, panelBottom,
82 RIGHT, panelRight)));
83 final var optionsMap = underTest.getGroupOptions();
84 assertThat(optionsMap.size(), is(4));
85 assertThat(optionsMap.get(LEFT), is(List.of(ALWAYS_WRAP)));
86 assertThat(optionsMap.get(CENTER), is(List.of(ALWAYS_WRAP)));
87 assertThat(optionsMap.get(BOTTOM), is(List.of(ALWAYS_WRAP)));
88 assertThat(optionsMap.get(RIGHT), is(List.of(ALWAYS_WRAP)));
89 assertThat(underTest.getOptions(), is(List.of(DISABLE_ACCORDION_ANIMATION)));
90 }
91 }