| Index: base/test/android/javatests/src/org/chromium/base/test/util/Matchers.java
|
| diff --git a/base/test/android/javatests/src/org/chromium/base/test/util/Matchers.java b/base/test/android/javatests/src/org/chromium/base/test/util/Matchers.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fc9d68907b34ac98efed8f76ab5a382e0c0e12f3
|
| --- /dev/null
|
| +++ b/base/test/android/javatests/src/org/chromium/base/test/util/Matchers.java
|
| @@ -0,0 +1,44 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.base.test.util;
|
| +
|
| +import org.hamcrest.CoreMatchers;
|
| +import org.hamcrest.Description;
|
| +import org.hamcrest.Matcher;
|
| +import org.hamcrest.TypeSafeMatcher;
|
| +
|
| +/**
|
| + * Helper class containing Hamcrest matchers.
|
| + */
|
| +public class Matchers extends CoreMatchers {
|
| + private static class GreaterThanOrEqualTo<T extends Comparable<T>>
|
| + extends TypeSafeMatcher<T> {
|
| +
|
| + private final T mComparisonValue;
|
| +
|
| + public GreaterThanOrEqualTo(T comparisonValue) {
|
| + mComparisonValue = comparisonValue;
|
| + }
|
| +
|
| + @Override
|
| + public void describeTo(Description description) {
|
| + description.appendText("greater than or equal to ").appendValue(mComparisonValue);
|
| + }
|
| +
|
| + @Override
|
| + protected boolean matchesSafely(T item) {
|
| + return item.compareTo(mComparisonValue) >= 0;
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * @param <T> A Comparable type.
|
| + * @param comparisonValue The value to be compared against.
|
| + * @return A matcher that expects the value to be greater than the |comparisonValue|.
|
| + */
|
| + public static <T extends Comparable<T>> Matcher<T> greaterThanOrEqualTo(T comparisonValue) {
|
| + return new GreaterThanOrEqualTo<>(comparisonValue);
|
| + }
|
| +}
|
|
|