コード例 #1
0
  @Test
  public void testItAbbreviatesDayNames() {
    // simulate Feb month
    when(calendar.get(Calendar.DAY_OF_WEEK)).thenReturn(1);
    when(calendar.get(Calendar.MONTH)).thenReturn(1);
    when(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)).thenReturn(28);

    underTest.setGrowProgress(
        1000); // set grow progress so that it simulates the calendar being open
    underTest.setLocale(Locale.FRANCE);
    reset(canvas); // reset because invalidate is called
    underTest.setUseWeekDayAbbreviation(true);
    reset(canvas); // reset because invalidate is called
    underTest.drawMonth(canvas, calendar, 0);

    DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(Locale.FRANCE);
    String[] dayNames = dateFormatSymbols.getShortWeekdays();

    InOrder inOrder = inOrder(canvas);
    inOrder.verify(canvas).drawText(eq(dayNames[2]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[3]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[4]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[5]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[6]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[7]), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq(dayNames[1]), anyInt(), anyInt(), eq(paint));
  }
コード例 #2
0
  @Test
  public void testItDrawsSundayAsFirstDay() {
    // simulate Feb month
    when(calendar.get(Calendar.DAY_OF_WEEK)).thenReturn(1);
    when(calendar.get(Calendar.MONTH)).thenReturn(1);
    when(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)).thenReturn(28);

    underTest.setGrowProgress(
        1000); // set grow progress so that it simulates the calendar being open
    underTest.setShouldShowMondayAsFirstDay(false);
    underTest.setUseWeekDayAbbreviation(true);
    underTest.drawMonth(canvas, calendar, 0);

    InOrder inOrder = inOrder(canvas);
    inOrder.verify(canvas).drawText(eq("Sun"), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq("Mon"), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq("Tue"), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq("Wed"), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq("Thu"), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq("Fri"), anyInt(), anyInt(), eq(paint));
    inOrder.verify(canvas).drawText(eq("Sat"), anyInt(), anyInt(), eq(paint));
  }