All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fest.assertions.api.android.hardware.usb.UsbDeviceAssert Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
// Copyright 2013 Square, Inc.
package org.fest.assertions.api.android.hardware.usb;

import android.hardware.usb.UsbDevice;
import org.fest.assertions.api.AbstractAssert;

import static org.fest.assertions.api.Assertions.assertThat;

/** Assertions for {@link UsbDevice} instances. */
public class UsbDeviceAssert extends AbstractAssert {
  public UsbDeviceAssert(UsbDevice actual) {
    super(actual, UsbDeviceAssert.class);
  }

  public UsbDeviceAssert hasDeviceClass(int value) {
    isNotNull();
    int actualValue = actual.getDeviceClass();
    assertThat(actualValue) //
        .overridingErrorMessage("Expected device class <%s> but was <%s>.", value, actualValue) //
        .isEqualTo(value);
    return this;
  }

  public UsbDeviceAssert hasDeviceId(int id) {
    isNotNull();
    int actualId = actual.getDeviceId();
    assertThat(actualId) //
        .overridingErrorMessage("Expected device id <%s> but was <%s>.", id, actualId) //
        .isEqualTo(id);
    return this;
  }

  public UsbDeviceAssert hasDeviceName(String name) {
    isNotNull();
    String actualName = actual.getDeviceName();
    assertThat(actualName) //
        .overridingErrorMessage("Expected device name <%s> but was <%s>.", name, actualName) //
        .isEqualTo(name);
    return this;
  }

  public UsbDeviceAssert hasDeviceProtocol(int protocol) {
    isNotNull();
    int actualProtocol = actual.getDeviceProtocol();
    assertThat(actualProtocol) //
        .overridingErrorMessage("Expected device protocol <%s> but was <%s>.", protocol,
            actualProtocol) //
        .isEqualTo(protocol);
    return this;
  }

  public UsbDeviceAssert hasDeviceSubclass(int subclass) {
    isNotNull();
    int actualSubclass = actual.getDeviceSubclass();
    assertThat(actualSubclass) //
        .overridingErrorMessage("Expected device subclass <%s> but was <%s>.", subclass,
            actualSubclass) //
        .isEqualTo(subclass);
    return this;
  }

  public UsbDeviceAssert hasInterfaceCount(int count) {
    isNotNull();
    int actualCount = actual.getInterfaceCount();
    assertThat(actualCount) //
        .overridingErrorMessage("Expected interface count <%s> but was <%s>.", count,
            actualCount) //
        .isEqualTo(count);
    return this;
  }

  public UsbDeviceAssert hasProductId(int id) {
    isNotNull();
    int actualId = actual.getProductId();
    assertThat(actualId) //
        .overridingErrorMessage("Expected product ID <%s> but was <%s>.", id, actualId) //
        .isEqualTo(id);
    return this;
  }

  public UsbDeviceAssert hasVendorId(int id) {
    isNotNull();
    int actualId = actual.getVendorId();
    assertThat(actualId) //
        .overridingErrorMessage("Expected vendor ID <%s> but was <%s>.", id, actualId) //
        .isEqualTo(id);
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy