Skip to content

Commit cad9df0

Browse files
Paige McAuliffecopybara-androidxtest
authored andcommitted
Remove Executor parameter from BaseSingleFoldDeviceAction
PiperOrigin-RevId: 549083553
1 parent 48dc2f5 commit cad9df0

File tree

6 files changed

+12
-23
lines changed

6 files changed

+12
-23
lines changed

espresso/device/java/androidx/test/espresso/device/action/BaseSingleFoldDeviceAction.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import androidx.window.layout.FoldingFeature
2828
import androidx.window.layout.WindowInfoTracker
2929
import androidx.window.layout.WindowLayoutInfo
3030
import java.util.concurrent.CountDownLatch
31-
import java.util.concurrent.Executor
3231
import java.util.concurrent.TimeUnit
3332
import kotlinx.coroutines.MainScope
3433
import kotlinx.coroutines.flow.collect
@@ -38,8 +37,7 @@ import kotlinx.coroutines.launch
3837
/** Action to set the test device to the provided device mode. */
3938
internal open class BaseSingleFoldDeviceAction(
4039
private val deviceMode: DeviceMode,
41-
private val foldingFeatureState: FoldingFeature.State?,
42-
private val mainExecutor: Executor
40+
private val foldingFeatureState: FoldingFeature.State?
4341
) : DeviceAction {
4442
protected var foldingFeatureOrientation: FoldingFeature.Orientation? = null
4543

espresso/device/java/androidx/test/espresso/device/action/BookModeAction.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import androidx.test.espresso.device.controller.DeviceMode
2323
import androidx.test.platform.app.InstrumentationRegistry
2424
import androidx.test.platform.device.DeviceController
2525
import androidx.window.layout.FoldingFeature
26-
import java.util.concurrent.Executor
2726

2827
/** Action to set the test device to be folded with the hinge in the vertical position. */
29-
internal class BookModeAction(private val mainExecutor: Executor) :
30-
BaseSingleFoldDeviceAction(DeviceMode.BOOK, FoldingFeature.State.HALF_OPENED, mainExecutor) {
28+
internal class BookModeAction() :
29+
BaseSingleFoldDeviceAction(DeviceMode.BOOK, FoldingFeature.State.HALF_OPENED) {
3130
companion object {
3231
private val TAG = BookModeAction::class.java.simpleName
3332
}

espresso/device/java/androidx/test/espresso/device/action/ClosedModeAction.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ import androidx.test.espresso.device.common.executeShellCommand
2121
import androidx.test.espresso.device.common.getMapOfDeviceStateNamesToIdentifiers
2222
import androidx.test.espresso.device.controller.DeviceMode
2323
import androidx.test.platform.device.DeviceController
24-
import java.util.concurrent.Executor
2524

2625
/** Action to set the test device to be closed. */
27-
internal class ClosedModeAction(private val mainExecutor: Executor) :
28-
BaseSingleFoldDeviceAction(DeviceMode.CLOSED, null, mainExecutor) {
26+
internal class ClosedModeAction() : BaseSingleFoldDeviceAction(DeviceMode.CLOSED, null) {
2927
override fun perform(deviceController: DeviceController) {
3028
val currentDeviceStateIdentifier = executeShellCommand("cmd device_state print-state").trim()
3129
if (currentDeviceStateIdentifier == getMapOfDeviceStateNamesToIdentifiers().get("CLOSED")) {

espresso/device/java/androidx/test/espresso/device/action/DeviceActions.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@
1818

1919
package androidx.test.espresso.device.action
2020

21-
import android.os.Handler
22-
import android.os.Looper
2321
import androidx.annotation.RestrictTo
2422
import androidx.annotation.RestrictTo.Scope
2523
import androidx.test.espresso.device.sizeclass.HeightSizeClass
2624
import androidx.test.espresso.device.sizeclass.WidthSizeClass
27-
import java.util.concurrent.Executor
2825

2926
/** Entry point for device action operations. */
30-
private val mainExecutor = Executor { command -> Handler(Looper.getMainLooper()).post(command) }
3127

3228
/**
3329
* Set device screen to be folded with the hinge in the horizontal position. For details on foldable
@@ -41,7 +37,7 @@ private val mainExecutor = Executor { command -> Handler(Looper.getMainLooper())
4137
* @throws DeviceControllerOperationException when called on a non-foldable Emulator.
4238
*/
4339
fun setTabletopMode(): DeviceAction {
44-
return TabletopModeAction(mainExecutor)
40+
return TabletopModeAction()
4541
}
4642

4743
/**
@@ -56,7 +52,7 @@ fun setTabletopMode(): DeviceAction {
5652
* @throws DeviceControllerOperationException when called on a non-foldable Emulator.
5753
*/
5854
fun setBookMode(): DeviceAction {
59-
return BookModeAction(mainExecutor)
55+
return BookModeAction()
6056
}
6157

6258
/**
@@ -70,7 +66,7 @@ fun setBookMode(): DeviceAction {
7066
* @throws DeviceControllerOperationException when called on a non-foldable Emulator.
7167
*/
7268
fun setFlatMode(): DeviceAction {
73-
return FlatModeAction(mainExecutor)
69+
return FlatModeAction()
7470
}
7571

7672
/**
@@ -83,7 +79,7 @@ fun setFlatMode(): DeviceAction {
8379
* @throws DeviceControllerOperationException when called on a non-foldable Emulator.
8480
*/
8581
fun setClosedMode(): DeviceAction {
86-
return ClosedModeAction(mainExecutor)
82+
return ClosedModeAction()
8783
}
8884

8985
/**

espresso/device/java/androidx/test/espresso/device/action/FlatModeAction.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ import androidx.test.espresso.device.common.getMapOfDeviceStateNamesToIdentifier
2222
import androidx.test.espresso.device.controller.DeviceMode
2323
import androidx.test.platform.device.DeviceController
2424
import androidx.window.layout.FoldingFeature
25-
import java.util.concurrent.Executor
2625

2726
/** Action to set the test device to be completely flat, like a tablet. */
28-
internal class FlatModeAction(private val mainExecutor: Executor) :
29-
BaseSingleFoldDeviceAction(DeviceMode.FLAT, FoldingFeature.State.FLAT, mainExecutor) {
27+
internal class FlatModeAction() :
28+
BaseSingleFoldDeviceAction(DeviceMode.FLAT, FoldingFeature.State.FLAT) {
3029
override fun perform(deviceController: DeviceController) {
3130
val currentDeviceStateIdentifier = executeShellCommand("cmd device_state print-state").trim()
3231
if (currentDeviceStateIdentifier == getMapOfDeviceStateNamesToIdentifiers().get("OPENED")) {

espresso/device/java/androidx/test/espresso/device/action/TabletopModeAction.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import androidx.test.espresso.device.controller.DeviceMode
2323
import androidx.test.platform.app.InstrumentationRegistry
2424
import androidx.test.platform.device.DeviceController
2525
import androidx.window.layout.FoldingFeature
26-
import java.util.concurrent.Executor
2726

2827
/** Action to set the test device to be folded with the hinge in a horizontal position. */
29-
internal class TabletopModeAction(private val mainExecutor: Executor) :
30-
BaseSingleFoldDeviceAction(DeviceMode.TABLETOP, FoldingFeature.State.HALF_OPENED, mainExecutor) {
28+
internal class TabletopModeAction() :
29+
BaseSingleFoldDeviceAction(DeviceMode.TABLETOP, FoldingFeature.State.HALF_OPENED) {
3130
companion object {
3231
private val TAG = TabletopModeAction::class.java.simpleName
3332
}

0 commit comments

Comments
 (0)