|
@@ -1,114 +0,0 @@
|
1
|
|
-/*
|
2
|
|
- * Copyright (c) 2006-2012 DMDirc Developers
|
3
|
|
- *
|
4
|
|
- * Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
|
- * of this software and associated documentation files (the "Software"), to deal
|
6
|
|
- * in the Software without restriction, including without limitation the rights
|
7
|
|
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
|
- * copies of the Software, and to permit persons to whom the Software is
|
9
|
|
- * furnished to do so, subject to the following conditions:
|
10
|
|
- *
|
11
|
|
- * The above copyright notice and this permission notice shall be included in
|
12
|
|
- * all copies or substantial portions of the Software.
|
13
|
|
- *
|
14
|
|
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
|
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
|
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
|
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
|
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
|
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
|
- * SOFTWARE.
|
21
|
|
- */
|
22
|
|
-
|
23
|
|
-package com.dmdirc.harness.ui;
|
24
|
|
-
|
25
|
|
-import com.dmdirc.ui.IconManager;
|
26
|
|
-import com.dmdirc.plugins.PluginInfo;
|
27
|
|
-import com.dmdirc.plugins.PluginMetaData;
|
28
|
|
-import com.dmdirc.Main;
|
29
|
|
-import com.dmdirc.WritableFrameContainer;
|
30
|
|
-import com.dmdirc.addons.ui_swing.MainFrame;
|
31
|
|
-import com.dmdirc.addons.ui_swing.SwingController;
|
32
|
|
-import com.dmdirc.addons.ui_swing.SwingWindowFactory;
|
33
|
|
-import com.dmdirc.config.ConfigManager;
|
34
|
|
-import com.dmdirc.config.IdentityManager;
|
35
|
|
-import com.dmdirc.config.InvalidIdentityFileException;
|
36
|
|
-import com.dmdirc.plugins.PluginManager;
|
37
|
|
-import com.dmdirc.ui.messages.IRCDocument;
|
38
|
|
-import com.dmdirc.updater.Version;
|
39
|
|
-
|
40
|
|
-import org.uispec4j.UISpecTestCase;
|
41
|
|
-import static org.mockito.Mockito.*;
|
42
|
|
-
|
43
|
|
-/**
|
44
|
|
- * Provides a basic test environment for testing the DMDirc Swing UI.
|
45
|
|
- */
|
46
|
|
-public class DMDircUITestCase extends UISpecTestCase {
|
47
|
|
-
|
48
|
|
- static {
|
49
|
|
- try {
|
50
|
|
- IdentityManager.getIdentityManager().initialise();
|
51
|
|
- } catch (InvalidIdentityFileException ex) {
|
52
|
|
- //Ignore
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
|
56
|
|
- IdentityManager.getAddonIdentity().setOption("test", "desktopbackground", "");
|
57
|
|
- IdentityManager.getAddonIdentity().setOption("test", "desktopbackgroundoption", "SCALE");
|
58
|
|
- IdentityManager.getAddonIdentity().setOption("test", "windowMenuItems", "1");
|
59
|
|
- IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
|
60
|
|
- Main.ensureExists(PluginManager.getPluginManager(), "tabcompletion");
|
61
|
|
- }
|
62
|
|
-
|
63
|
|
- /**
|
64
|
|
- * Returns a mocked SwingController.
|
65
|
|
- *
|
66
|
|
- * @return SwingController mock
|
67
|
|
- */
|
68
|
|
- public static SwingController getMockedController() {
|
69
|
|
- final PluginInfo pluginInfo = mock(PluginInfo.class);
|
70
|
|
- final PluginMetaData metaData = mock(PluginMetaData.class);
|
71
|
|
- final SwingController controller = mock(SwingController.class);
|
72
|
|
- final SwingWindowFactory windowFactory = mock(SwingWindowFactory.class);
|
73
|
|
- when(controller.getDomain()).thenReturn("test");
|
74
|
|
- when(controller.getWindowFactory()).thenReturn(windowFactory);
|
75
|
|
- when(controller.getVersion()).thenReturn(new Version(1));
|
76
|
|
- when(pluginInfo.getMetaData()).thenReturn(metaData);
|
77
|
|
- when(metaData.getVersion()).thenReturn(new Version(1));
|
78
|
|
-
|
79
|
|
- return controller;
|
80
|
|
- }
|
81
|
|
-
|
82
|
|
- /**
|
83
|
|
- * Returns a mocked SwingController that contains a mocked Main Frame.
|
84
|
|
- *
|
85
|
|
- * @return SwingController + MainFrame mock
|
86
|
|
- */
|
87
|
|
- public static SwingController getMockedControllerAndMainFrame() {
|
88
|
|
- SwingController controller = getMockedController();
|
89
|
|
- final MainFrame mainFrame = new MainFrame(controller);
|
90
|
|
- when(controller.getMainFrame()).thenReturn(mainFrame);
|
91
|
|
-
|
92
|
|
- return controller;
|
93
|
|
- }
|
94
|
|
-
|
95
|
|
- /**
|
96
|
|
- * Returns a mocked WritableFrameContainer.
|
97
|
|
- *
|
98
|
|
- * @return FrameContainer mock
|
99
|
|
- */
|
100
|
|
- public static WritableFrameContainer getMockedContainer() {
|
101
|
|
- final IRCDocument document = mock(IRCDocument.class);
|
102
|
|
- @SuppressWarnings("unchecked")
|
103
|
|
- final WritableFrameContainer container = mock(
|
104
|
|
- WritableFrameContainer.class);
|
105
|
|
- final ConfigManager config = mock(ConfigManager.class);
|
106
|
|
- final IconManager iconManager = mock(IconManager.class);
|
107
|
|
- when(container.getDocument()).thenReturn(document);
|
108
|
|
- when(container.getConfigManager()).thenReturn(config);
|
109
|
|
- when(config.getOption(anyString(), anyString())).thenReturn("mirc");
|
110
|
|
- when(container.getIconManager()).thenReturn(iconManager);
|
111
|
|
-
|
112
|
|
- return container;
|
113
|
|
- }
|
114
|
|
-}
|