Example usage for android.widget RatingBar getNumStars

List of usage examples for android.widget RatingBar getNumStars

Introduction

In this page you can find the example usage for android.widget RatingBar getNumStars.

Prototype

public int getNumStars() 

Source Link

Document

Returns the number of stars shown.

Usage

From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapterTest.java

@Test
public void testGetView() throws Exception {
    // setup/*from   ww w .  ja v a 2 s.c o  m*/
    int expectedSize = Strength.values().length;
    Strength expectedStrength = Strength.reverse(Strength.FOUR);
    WiFiChannel wiFiChannel = new WiFiChannel(1, 2);
    fixture.add(wiFiChannel);
    when(channelRating.getCount(wiFiChannel)).thenReturn(5);
    when(channelRating.getStrength(wiFiChannel)).thenReturn(Strength.FOUR);
    // execute
    View actual = fixture.getView(0, null, null);
    // validate
    assertNotNull(actual);

    assertEquals("1", ((TextView) actual.findViewById(R.id.channelNumber)).getText());
    assertEquals("5", ((TextView) actual.findViewById(R.id.accessPointCount)).getText());

    RatingBar ratingBar = (RatingBar) actual.findViewById(R.id.channelRating);
    assertEquals(expectedSize, ratingBar.getMax());
    assertEquals(expectedSize, ratingBar.getNumStars());
    assertEquals(expectedStrength.ordinal() + 1, (int) ratingBar.getRating());

    assertEquals("", bestChannels.getText());

    verify(channelRating).getCount(wiFiChannel);
    verify(channelRating).getStrength(wiFiChannel);
}