com.pkware.truth.android.playservices.location.LocationRequestSubject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truth-android-play-services Show documentation
Show all versions of truth-android-play-services Show documentation
A set of Truth subjects geared toward testing Android.
/*
* Copyright 2013 Square, Inc.
* Copyright 2016 PKWARE, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.pkware.truth.android.playservices.location;
import com.google.android.gms.location.LocationRequest;
import com.google.common.truth.FailureStrategy;
import com.google.common.truth.Subject;
import com.google.common.truth.SubjectFactory;
import static com.google.common.truth.Truth.assertThat;
/**
* Propositions for {@link LocationRequest} subjects.
*/
public class LocationRequestSubject extends Subject {
protected LocationRequestSubject(FailureStrategy failureStrategy, LocationRequest subject) {
super(failureStrategy, subject);
}
public static SubjectFactory type() {
return new SubjectFactory() {
@Override
public LocationRequestSubject getSubject(FailureStrategy fs, LocationRequest that) {
return new LocationRequestSubject(fs, that);
}
};
}
public LocationRequestSubject hasExpirationTime(long time) {
assertThat(actual().getExpirationTime())
.named("expiration time")
.isEqualTo(time);
return this;
}
public LocationRequestSubject hasFastestInterval(long interval) {
assertThat(actual().getFastestInterval())
.named("fastest interval")
.isEqualTo(interval);
return this;
}
public LocationRequestSubject hasInterval(long interval) {
long actualInterval = actual().getInterval();
assertThat(actual().getInterval())
.named("interval")
.isEqualTo(interval);
return this;
}
public LocationRequestSubject hasUpdates(int updates) {
assertThat(actual().getNumUpdates())
.named("update count")
.isEqualTo(updates);
return this;
}
public LocationRequestSubject hasPriority(int priority) {
assertThat(actual().getPriority())
.named("priority")
.isEqualTo(priority);
return this;
}
public LocationRequestSubject hasSmallestDisplacement(float displacement, float tolerance) {
assertThat(actual().getSmallestDisplacement())
.named("smallest displacement")
.isWithin(tolerance)
.of(displacement);
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy