From c9e692672ad92cd208580a849001d808d927b662 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Fri, 3 Jan 2025 12:04:39 -0800 Subject: [PATCH] Minor updates after recent changes for Java 8 APIs. RELNOTES=n/a PiperOrigin-RevId: 711817437 --- .../common/base/StopwatchJavaTimeTest.java | 41 +++++++++++++++++++ .../common/collect/CollectCollectors.java | 1 - .../common/collect/TableCollectors.java | 1 - 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 android/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java diff --git a/android/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java b/android/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java new file mode 100644 index 000000000000..71bcfc740779 --- /dev/null +++ b/android/guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2008 The Guava Authors + * + * 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.google.common.base; + +import com.google.common.annotations.GwtIncompatible; +import com.google.common.annotations.J2ktIncompatible; +import com.google.common.testing.FakeTicker; +import java.time.Duration; +import junit.framework.TestCase; +import org.jspecify.annotations.NullUnmarked; + +/** Unit test for the {@code java.time} support in {@link Stopwatch}. */ +@J2ktIncompatible +@GwtIncompatible +@NullUnmarked +public class StopwatchJavaTimeTest extends TestCase { + private final FakeTicker ticker = new FakeTicker(); + private final Stopwatch stopwatch = new Stopwatch(ticker); + + public void testElapsed_duration() { + stopwatch.start(); + ticker.advance(999999); + assertEquals(Duration.ofNanos(999999), stopwatch.elapsed()); + ticker.advance(1); + assertEquals(Duration.ofMillis(1), stopwatch.elapsed()); + } +} diff --git a/android/guava/src/com/google/common/collect/CollectCollectors.java b/android/guava/src/com/google/common/collect/CollectCollectors.java index 65d76536b279..f12c882093ce 100644 --- a/android/guava/src/com/google/common/collect/CollectCollectors.java +++ b/android/guava/src/com/google/common/collect/CollectCollectors.java @@ -42,7 +42,6 @@ @GwtCompatible @SuppressWarnings("Java7ApiChecker") @IgnoreJRERequirement // used only from APIs with Java 8 types in them -// (not used publicly by guava-android as of this writing, but we include it in the jar as a test) final class CollectCollectors { private static final Collector> TO_IMMUTABLE_LIST = diff --git a/android/guava/src/com/google/common/collect/TableCollectors.java b/android/guava/src/com/google/common/collect/TableCollectors.java index ed199dde9510..1db160bff5a7 100644 --- a/android/guava/src/com/google/common/collect/TableCollectors.java +++ b/android/guava/src/com/google/common/collect/TableCollectors.java @@ -32,7 +32,6 @@ @GwtCompatible @SuppressWarnings("Java7ApiChecker") @IgnoreJRERequirement // used only from APIs with Java 8 types in them -// (not used publicly by guava-android as of this writing, but we include it in the jar as a test) final class TableCollectors { static