@@ -1469,6 +1469,107 @@ class PcMouseControlViewModelTest {
14691469 assertEquals(PcMouseControlViewModel .COMMAND_FAILED_MESSAGE , viewModel.uiState.value.message)
14701470 }
14711471
1472+ @Test
1473+ fun leftClickClearsDraggingAfterSuccessfulSend () = runTest(dispatcher) {
1474+ val connector = FakeConnector ()
1475+ val controller = connectedController(connector = connector)
1476+ val viewModel = viewModel(controller)
1477+
1478+ viewModel.send(PcControlCommand .DragStart ())
1479+ advanceUntilIdle()
1480+ viewModel.send(PcControlCommand .LeftClick )
1481+ advanceUntilIdle()
1482+
1483+ assertEquals(
1484+ listOf (PcControlCommand .DragStart (), PcControlCommand .LeftClick ),
1485+ connector.realtimeCommands
1486+ )
1487+ assertFalse(viewModel.uiState.value.isDragging)
1488+ }
1489+
1490+ @Test
1491+ fun rightClickClearsDraggingAfterSuccessfulSend () = runTest(dispatcher) {
1492+ val controller = connectedController()
1493+ val viewModel = viewModel(controller)
1494+
1495+ viewModel.send(PcControlCommand .DragStart ())
1496+ advanceUntilIdle()
1497+ viewModel.send(PcControlCommand .RightClick )
1498+ advanceUntilIdle()
1499+
1500+ assertFalse(viewModel.uiState.value.isDragging)
1501+ }
1502+
1503+ @Test
1504+ fun doubleClickClearsDraggingAfterSuccessfulSend () = runTest(dispatcher) {
1505+ val controller = connectedController()
1506+ val viewModel = viewModel(controller)
1507+
1508+ viewModel.send(PcControlCommand .DragStart ())
1509+ advanceUntilIdle()
1510+ viewModel.send(PcControlCommand .DoubleClick )
1511+ advanceUntilIdle()
1512+
1513+ assertFalse(viewModel.uiState.value.isDragging)
1514+ }
1515+
1516+ @Test
1517+ fun failedClickDoesNotClearDraggingMirror () = runTest(dispatcher) {
1518+ val connector = FakeConnector (
1519+ realtimeResults = mutableListOf (PcCommandResult .Ack , PcCommandResult .Failed ())
1520+ )
1521+ val controller = connectedController(connector = connector)
1522+ val viewModel = viewModel(controller)
1523+
1524+ viewModel.send(PcControlCommand .DragStart ())
1525+ advanceUntilIdle()
1526+ viewModel.send(PcControlCommand .LeftClick )
1527+ advanceUntilIdle()
1528+
1529+ assertTrue(viewModel.uiState.value.isDragging)
1530+ assertEquals(PcMouseControlViewModel .COMMAND_FAILED_MESSAGE , viewModel.uiState.value.message)
1531+ }
1532+
1533+ @Test
1534+ fun moveDoesNotClearDragging () = runTest(dispatcher) {
1535+ val controller = connectedController()
1536+ val viewModel = viewModel(controller)
1537+
1538+ viewModel.send(PcControlCommand .DragStart ())
1539+ advanceUntilIdle()
1540+ viewModel.send(PcControlCommand .Move (dx = 10 , dy = 0 ))
1541+ advanceUntilIdle()
1542+
1543+ assertTrue(viewModel.uiState.value.isDragging)
1544+ }
1545+
1546+ @Test
1547+ fun scrollDoesNotClearDragging () = runTest(dispatcher) {
1548+ val controller = connectedController()
1549+ val viewModel = viewModel(controller)
1550+
1551+ viewModel.send(PcControlCommand .DragStart ())
1552+ advanceUntilIdle()
1553+ viewModel.send(PcControlCommand .Scroll (dx = 0 , dy = - 1 ))
1554+ advanceUntilIdle()
1555+
1556+ assertTrue(viewModel.uiState.value.isDragging)
1557+ }
1558+
1559+ @Test
1560+ fun modifierToggleDoesNotClearDragging () = runTest(dispatcher) {
1561+ val controller = connectedController(pointerProfile = modifierPointerProfile())
1562+ val viewModel = viewModel(controller)
1563+ advanceUntilIdle()
1564+
1565+ viewModel.send(PcControlCommand .DragStart ())
1566+ advanceUntilIdle()
1567+ viewModel.toggleModifier(PcKeyboardModifierKey .Ctrl )
1568+ advanceUntilIdle()
1569+
1570+ assertTrue(viewModel.uiState.value.isDragging)
1571+ }
1572+
14721573 @Test
14731574 fun supportedProfileEnablesModifierToggles () = runTest(dispatcher) {
14741575 val controller = connectedController(pointerProfile = modifierPointerProfile())
0 commit comments