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.assertj.core.api.Assertions.assertThat;
35 import static org.mockito.Mockito.*;
36
37 /***************************************************************************************************************************************************************
38 *
39 * @author Fabrizio Giudici
40 *
41 **************************************************************************************************************************************************************/
42 public class PanelGroupControlTest
43 {
44 static class Fixture implements PanelGroupControl<MockPanel>
45 {
46 @Override
47 public void setup (@Nonnull final Configuration<MockPanel> configuration)
48 {
49 // not needed in tests
50 }
51
52 @Override
53 public void show (@Nonnull final Object object)
54 {
55 // not needed in tests
56 }
57 }
58
59 static class MockPanel {}
60
61 @Test
62 public void test_Configuration()
63 {
64 // given
65 final var panelLeft = mock(MockPanel.class);
66 final var panelCenter = mock(MockPanel.class);
67 final var panelBottom = mock(MockPanel.class);
68 final var panelRight = mock(MockPanel.class);
69 final var f = new Fixture(); // needed only for calling config()
70 // when
71 final var underTest = f.config()
72 .withGroup(LEFT, panelLeft, ALWAYS_WRAP)
73 .withGroup(CENTER, panelCenter, ALWAYS_WRAP)
74 .withGroup(BOTTOM, panelBottom, ALWAYS_WRAP)
75 .withGroup(RIGHT, panelRight, ALWAYS_WRAP)
76 .withOptions(DISABLE_ACCORDION_ANIMATION);
77 // then
78 assertThat(underTest.getTopContainersByGroup()).isEqualTo(Map.of(LEFT, panelLeft,
79 CENTER, panelCenter,
80 BOTTOM, panelBottom,
81 RIGHT, panelRight));
82 final var optionsMap = underTest.getGroupOptions();
83 assertThat(optionsMap).hasSize(4)
84 .containsEntry(LEFT, List.of(ALWAYS_WRAP))
85 .containsEntry(CENTER, List.of(ALWAYS_WRAP))
86 .containsEntry(BOTTOM, List.of(ALWAYS_WRAP))
87 .containsEntry(RIGHT, List.of(ALWAYS_WRAP));
88 assertThat(underTest.getOptions()).isEqualTo(List.of(DISABLE_ACCORDION_ANIMATION));
89 }
90 }