@@ -1767,6 +1767,42 @@ class AdapterTest
1767
1767
VERIFY_THROWS (_pDispatch->TertiaryDeviceAttributes (), std::exception );
1768
1768
}
1769
1769
1770
+ TEST_METHOD (RequestDisplayedExtentTests)
1771
+ {
1772
+ Log::Comment (L" Starting test..." );
1773
+
1774
+ Log::Comment (L" Test 1: Verify DECRQDE response in home position" );
1775
+ _testGetSet->PrepData ();
1776
+ _testGetSet->_viewport .left = 0 ;
1777
+ _testGetSet->_viewport .right = 80 ;
1778
+ _testGetSet->_viewport .top = 0 ;
1779
+ _testGetSet->_viewport .bottom = 24 ;
1780
+ VERIFY_IS_TRUE (_pDispatch->RequestDisplayedExtent ());
1781
+ _testGetSet->ValidateInputEvent (L" \x1b [24;80;1;1;1\" w" );
1782
+
1783
+ Log::Comment (L" Test 2: Verify DECRQDE response when panned horizontally" );
1784
+ _testGetSet->_viewport .left += 5 ;
1785
+ _testGetSet->_viewport .right += 5 ;
1786
+ VERIFY_IS_TRUE (_pDispatch->RequestDisplayedExtent ());
1787
+ _testGetSet->ValidateInputEvent (L" \x1b [24;80;6;1;1\" w" );
1788
+
1789
+ Log::Comment (L" Test 3: Verify DECRQDE response on page 3" );
1790
+ _pDispatch->PagePositionAbsolute (3 );
1791
+ VERIFY_IS_TRUE (_pDispatch->RequestDisplayedExtent ());
1792
+ _testGetSet->ValidateInputEvent (L" \x1b [24;80;6;1;3\" w" );
1793
+
1794
+ Log::Comment (L" Test 3: Verify DECRQDE response when active page not visible" );
1795
+ _pDispatch->ResetMode (DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode);
1796
+ _pDispatch->PagePositionAbsolute (1 );
1797
+ VERIFY_IS_TRUE (_pDispatch->RequestDisplayedExtent ());
1798
+ _testGetSet->ValidateInputEvent (L" \x1b [24;80;6;1;3\" w" );
1799
+
1800
+ Log::Comment (L" Test 4: Verify DECRQDE response when page 1 visible again" );
1801
+ _pDispatch->SetMode (DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode);
1802
+ VERIFY_IS_TRUE (_pDispatch->RequestDisplayedExtent ());
1803
+ _testGetSet->ValidateInputEvent (L" \x1b [24;80;6;1;1\" w" );
1804
+ }
1805
+
1770
1806
TEST_METHOD (RequestTerminalParametersTests)
1771
1807
{
1772
1808
Log::Comment (L" Starting test..." );
@@ -3367,6 +3403,89 @@ class AdapterTest
3367
3403
VERIFY_IS_TRUE (_pDispatch->DoVsCodeAction (LR"( Completions;10;20;30;{ "foo": "what;ever", "bar": 2 })" ));
3368
3404
}
3369
3405
3406
+ TEST_METHOD (PageMovementTests)
3407
+ {
3408
+ _testGetSet->PrepData (CursorX::XCENTER, CursorY::YCENTER);
3409
+ auto & pages = _pDispatch->_pages ;
3410
+ const auto startPos = pages.ActivePage ().Cursor ().GetPosition ();
3411
+ const auto homePos = til::point{ 0 , pages.ActivePage ().Top () };
3412
+
3413
+ // Testing PPA (page position absolute)
3414
+ VERIFY_ARE_EQUAL (1 , pages.ActivePage ().Number (), L" Initial page is 1" );
3415
+ _pDispatch->PagePositionAbsolute (3 );
3416
+ VERIFY_ARE_EQUAL (3 , pages.ActivePage ().Number (), L" PPA 3 moves to page 3" );
3417
+ _pDispatch->PagePositionAbsolute (VTParameter{});
3418
+ VERIFY_ARE_EQUAL (1 , pages.ActivePage ().Number (), L" PPA with omitted page moves to 1" );
3419
+ _pDispatch->PagePositionAbsolute (9999 );
3420
+ VERIFY_ARE_EQUAL (6 , pages.ActivePage ().Number (), L" PPA is clamped at page 6" );
3421
+ VERIFY_ARE_EQUAL (startPos, pages.ActivePage ().Cursor ().GetPosition (), L" Cursor position never changes" );
3422
+
3423
+ _testGetSet->PrepData (CursorX::XCENTER, CursorY::YCENTER);
3424
+ _pDispatch->PagePositionAbsolute (1 ); // Reset to page 1
3425
+
3426
+ // Testing PPR (page position relative)
3427
+ VERIFY_ARE_EQUAL (1 , pages.ActivePage ().Number (), L" Initial page is 1" );
3428
+ _pDispatch->PagePositionRelative (2 );
3429
+ VERIFY_ARE_EQUAL (3 , pages.ActivePage ().Number (), L" PPR 2 moves forward 2 pages" );
3430
+ _pDispatch->PagePositionRelative (VTParameter{});
3431
+ VERIFY_ARE_EQUAL (4 , pages.ActivePage ().Number (), L" PPR with omitted count moves forward 1" );
3432
+ _pDispatch->PagePositionRelative (9999 );
3433
+ VERIFY_ARE_EQUAL (6 , pages.ActivePage ().Number (), L" PPR is clamped at page 6" );
3434
+ VERIFY_ARE_EQUAL (startPos, pages.ActivePage ().Cursor ().GetPosition (), L" Cursor position never changes" );
3435
+
3436
+ _testGetSet->PrepData (CursorX::XCENTER, CursorY::YCENTER);
3437
+
3438
+ // Testing PPB (page position back)
3439
+ VERIFY_ARE_EQUAL (6 , pages.ActivePage ().Number (), L" Initial page is 6" );
3440
+ _pDispatch->PagePositionBack (2 );
3441
+ VERIFY_ARE_EQUAL (4 , pages.ActivePage ().Number (), L" PPB 2 moves back 2 pages" );
3442
+ _pDispatch->PagePositionBack (VTParameter{});
3443
+ VERIFY_ARE_EQUAL (3 , pages.ActivePage ().Number (), L" PPB with omitted count moves back 1" );
3444
+ _pDispatch->PagePositionBack (9999 );
3445
+ VERIFY_ARE_EQUAL (1 , pages.ActivePage ().Number (), L" PPB is clamped at page 1" );
3446
+ VERIFY_ARE_EQUAL (startPos, pages.ActivePage ().Cursor ().GetPosition (), L" Cursor position never changes" );
3447
+
3448
+ _testGetSet->PrepData (CursorX::XCENTER, CursorY::YCENTER);
3449
+
3450
+ // Testing NP (next page)
3451
+ VERIFY_ARE_EQUAL (1 , pages.ActivePage ().Number (), L" Initial page is 1" );
3452
+ _pDispatch->NextPage (2 );
3453
+ VERIFY_ARE_EQUAL (3 , pages.ActivePage ().Number (), L" NP 2 moves forward 2 pages" );
3454
+ _pDispatch->NextPage (VTParameter{});
3455
+ VERIFY_ARE_EQUAL (4 , pages.ActivePage ().Number (), L" NP with omitted count moves forward 1" );
3456
+ _pDispatch->NextPage (9999 );
3457
+ VERIFY_ARE_EQUAL (6 , pages.ActivePage ().Number (), L" NP is clamped at page 6" );
3458
+ VERIFY_ARE_EQUAL (homePos, pages.ActivePage ().Cursor ().GetPosition (), L" Cursor position is reset to home" );
3459
+
3460
+ _testGetSet->PrepData (CursorX::XCENTER, CursorY::YCENTER);
3461
+
3462
+ // Testing PP (preceding page)
3463
+ VERIFY_ARE_EQUAL (6 , pages.ActivePage ().Number (), L" Initial page is 6" );
3464
+ _pDispatch->PrecedingPage (2 );
3465
+ VERIFY_ARE_EQUAL (4 , pages.ActivePage ().Number (), L" PP 2 moves back 2 pages" );
3466
+ _pDispatch->PrecedingPage (VTParameter{});
3467
+ VERIFY_ARE_EQUAL (3 , pages.ActivePage ().Number (), L" PP with omitted count moves back 1" );
3468
+ _pDispatch->PrecedingPage (9999 );
3469
+ VERIFY_ARE_EQUAL (1 , pages.ActivePage ().Number (), L" PP is clamped at page 1" );
3470
+ VERIFY_ARE_EQUAL (homePos, pages.ActivePage ().Cursor ().GetPosition (), L" Cursor position is reset to home" );
3471
+
3472
+ // Testing DECPCCM (page cursor coupling mode)
3473
+ _pDispatch->SetMode (DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode);
3474
+ _pDispatch->PagePositionAbsolute (2 );
3475
+ VERIFY_ARE_EQUAL (2 , pages.ActivePage ().Number ());
3476
+ VERIFY_ARE_EQUAL (2 , pages.VisiblePage ().Number (), L" Visible page should follow active if DECPCCM set" );
3477
+ _pDispatch->ResetMode (DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode);
3478
+ _pDispatch->PagePositionAbsolute (4 );
3479
+ VERIFY_ARE_EQUAL (4 , pages.ActivePage ().Number ());
3480
+ VERIFY_ARE_EQUAL (2 , pages.VisiblePage ().Number (), L" Visible page should not change if DECPCCM reset" );
3481
+ _pDispatch->SetMode (DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode);
3482
+ VERIFY_ARE_EQUAL (4 , pages.ActivePage ().Number ());
3483
+ VERIFY_ARE_EQUAL (4 , pages.VisiblePage ().Number (), L" Active page should become visible when DECPCCM set" );
3484
+
3485
+ // Reset to page 1
3486
+ _pDispatch->PagePositionAbsolute (1 );
3487
+ }
3488
+
3370
3489
private:
3371
3490
TerminalInput _terminalInput;
3372
3491
std::unique_ptr<TestGetSet> _testGetSet;
0 commit comments