From ee374f392908a068f834247862cef5a6c50144e9 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 28 Mar 2018 14:02:13 -0600 Subject: [PATCH] API council requested tweaks to NetworkRequest. If you put values into the Builder, you should be able to observe those values on the built object. Test: atest android.net.cts.NetworkRequestTest Bug: 74945408 Change-Id: I894a82c10eb13c46fb764384e6c5348dde8df154 --- .../android/net/cts/NetworkRequestTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/cts/net/src/android/net/cts/NetworkRequestTest.java diff --git a/tests/cts/net/src/android/net/cts/NetworkRequestTest.java b/tests/cts/net/src/android/net/cts/NetworkRequestTest.java new file mode 100644 index 0000000000..c862c77bc7 --- /dev/null +++ b/tests/cts/net/src/android/net/cts/NetworkRequestTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * 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 android.net.cts; + +import static android.net.NetworkCapabilities.NET_CAPABILITY_MMS; +import static android.net.NetworkCapabilities.TRANSPORT_BLUETOOTH; + +import android.net.NetworkRequest; +import android.test.AndroidTestCase; + +public class NetworkRequestTest extends AndroidTestCase { + public void testCapabilities() { + assertTrue(new NetworkRequest.Builder().addCapability(NET_CAPABILITY_MMS).build() + .hasCapability(NET_CAPABILITY_MMS)); + assertFalse(new NetworkRequest.Builder().removeCapability(NET_CAPABILITY_MMS).build() + .hasCapability(NET_CAPABILITY_MMS)); + } + + public void testTransports() { + assertTrue(new NetworkRequest.Builder().addTransportType(TRANSPORT_BLUETOOTH).build() + .hasTransport(TRANSPORT_BLUETOOTH)); + assertFalse(new NetworkRequest.Builder().removeTransportType(TRANSPORT_BLUETOOTH).build() + .hasTransport(TRANSPORT_BLUETOOTH)); + } +}