Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

StatusMessageTest.java 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2006-2015 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
  20. * THE SOFTWARE.
  21. */
  22. package com.dmdirc.ui;
  23. import com.dmdirc.config.provider.AggregateConfigProvider;
  24. import com.dmdirc.interfaces.ui.StatusMessageNotifier;
  25. import org.junit.Test;
  26. import static org.junit.Assert.*;
  27. import static org.mockito.Mockito.*;
  28. public class StatusMessageTest {
  29. @Test
  30. public void testGetMessageShortConstructor() {
  31. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  32. final StatusMessage instance = new StatusMessage("test", config);
  33. assertEquals("test", instance.getMessage());
  34. }
  35. @Test
  36. public void testGetMessageLongConstructor() {
  37. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  38. final StatusMessage instance = new StatusMessage("icon", "test", null, 10, config);
  39. assertEquals("test", instance.getMessage());
  40. }
  41. @Test
  42. public void testGetIconType() {
  43. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  44. final StatusMessage instance = new StatusMessage("icon", "test", null, 10, config);
  45. assertEquals("icon", instance.getIconType());
  46. }
  47. @Test
  48. public void testGetMessageNotifierNull() {
  49. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  50. final StatusMessage instance = new StatusMessage("icon", "test", null, 10, config);
  51. assertNull(instance.getMessageNotifier());
  52. }
  53. @Test
  54. public void testGetMessageNotifierNotNull() {
  55. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  56. final StatusMessageNotifier smn = mock(StatusMessageNotifier.class);
  57. final StatusMessage instance = new StatusMessage("icon", "test", smn, 10, config);
  58. assertEquals(smn, instance.getMessageNotifier());
  59. }
  60. @Test
  61. public void testGetTimeout() {
  62. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  63. final StatusMessage instance = new StatusMessage("icon", "test", null, 10, config);
  64. assertEquals(10, instance.getTimeout());
  65. }
  66. @Test
  67. public void testGetTimeoutFallback() {
  68. final AggregateConfigProvider config = mock(AggregateConfigProvider.class);
  69. when(config.getOptionInt("statusBar", "messageDisplayLength")).thenReturn(10);
  70. final StatusMessage instance = new StatusMessage("icon", "test", null, -1, config);
  71. assertEquals(10, instance.getTimeout());
  72. }
  73. }