Пример #1
0
  @Test(expected = IllegalStateException.class)
  public void loop_checksDisposed() {
    ColorSequence sequence = new ColorSequence(display, rgb1, rgb2);
    sequence.dispose();

    sequence.loop();
  }
Пример #2
0
  @Test
  public void isDispose_trueAfterDispose() {
    ColorSequence sequence = new ColorSequence(display, rgb1);
    sequence.dispose();

    assertTrue(sequence.isDisposed());
  }
Пример #3
0
  @Test(expected = IllegalStateException.class)
  public void get_checksDispose() {
    ColorSequence sequence = new ColorSequence(display, rgb1);
    sequence.dispose();

    sequence.get(0);
  }
Пример #4
0
  @Test
  public void loop_createsStreamWithSingleColor() {
    ColorSequence sequence = new ColorSequence(display, rgb1);

    ColorStream stream = sequence.loop();

    assertEquals(new Color(display, rgb1), stream.next());
  }
Пример #5
0
  @Test
  public void size() {
    ColorSequence sequence = new ColorSequence(display, rgb1, rgb2, rgb3);

    int size = sequence.size();

    assertEquals(3, size);
  }
Пример #6
0
  @Test
  public void dispose_disposesColors() {
    ColorSequence sequence = new ColorSequence(display, rgb1);
    Color color = sequence.get(0);

    sequence.dispose();

    assertTrue(color.isDisposed());
  }
Пример #7
0
  @Test
  public void keepsSafeCopyOfColorsArray() {
    RGB[] colors = {rgb1, rgb2, rgb3};
    ColorSequence sequence = new ColorSequence(display, colors);

    colors[0] = new RGB(47, 47, 47);
    ColorStream stream = sequence.loop();

    assertEquals(new Color(display, rgb1), stream.next());
  }
Пример #8
0
  @Test
  public void loop_createsLoopingStream() {
    ColorSequence sequence = new ColorSequence(display, rgb1, rgb2);

    ColorStream stream = sequence.loop();

    assertEquals(new Color(display, rgb1), stream.next());
    assertEquals(new Color(display, rgb2), stream.next());
    assertEquals(new Color(display, rgb1), stream.next());
  }
Пример #9
0
  @Test
  public void loop_createsStreamWithMultipleColors() {
    ColorSequence sequence = new ColorSequence(display, rgb1, rgb2, rgb3);

    ColorStream stream = sequence.loop();

    assertEquals(new Color(display, rgb1), stream.next());
    assertEquals(new Color(display, rgb2), stream.next());
    assertEquals(new Color(display, rgb3), stream.next());
  }
Пример #10
0
  @Test
  public void isDispose_falseByDefault() {
    ColorSequence sequence = new ColorSequence(display, rgb1);

    assertFalse(sequence.isDisposed());
  }
Пример #11
0
  @Test(expected = IndexOutOfBoundsException.class)
  public void get_failsWithNegativeIndex() {
    ColorSequence sequence = new ColorSequence(display, rgb1);

    sequence.get(-1);
  }