1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.test; 17 18 import com.android.tradefed.config.Option; 19 import com.android.tradefed.device.DeviceNotAvailableException; 20 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 21 import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; 22 import com.android.tradefed.util.RunUtil; 23 24 import org.junit.Test; 25 import org.junit.runner.RunWith; 26 27 @RunWith(DeviceJUnit4ClassRunner.class) 28 public final class DeviceLongPollingStubTest extends BaseHostJUnit4Test { 29 30 @Option(name = "duration", description = "Device long polling duration in seconds.") 31 private int mLongPollingDurationSec = 2 * 60 * 60; 32 33 @Option(name = "connection-check-interval", description = "Interval for adb connection checks.") 34 private int mConnectionCheckIntervalSec = 60; 35 36 @Test testDeviceLongPolling()37 public void testDeviceLongPolling() throws DeviceNotAvailableException { 38 for (int i = 0; i < mLongPollingDurationSec / mConnectionCheckIntervalSec; i++) { 39 getDevice().executeShellCommand("log connecting_to_device"); 40 RunUtil.getDefault().sleep(mConnectionCheckIntervalSec * 1000); 41 } 42 } 43 } 44