@@ -1584,6 +1584,48 @@ public void TestFind()
1584
1584
// find should not modify the document, so we should be able to exit without saveas dialog.
1585
1585
}
1586
1586
1587
+ [ TestMethod ]
1588
+ [ Timeout ( TestMethodTimeout ) ]
1589
+ public void TestReplaceMany ( )
1590
+ {
1591
+ ResetFindOptions ( ) ;
1592
+
1593
+ Trace . WriteLine ( "TestReplace==========================================================" ) ;
1594
+ string testFile = _testDir + "UnitTests\\ test10.xml" ;
1595
+ var w = LaunchNotepad ( testFile ) ;
1596
+
1597
+ w . SendKeystrokes ( "{HOME}" ) ;
1598
+ w . SendKeystrokes ( "^c" ) ;
1599
+ var original = GetClipboardText ( ) ;
1600
+ var findDialog = OpenReplaceDialog ( ) ;
1601
+
1602
+ // replace all instances of "item" with something longer "xxxxxxx";
1603
+ findDialog . Window . SendKeystrokes ( "item{TAB}xxxxxxx%a" ) ;
1604
+ findDialog . Window . DismissPopUp ( "{ESC}" ) ;
1605
+
1606
+ w . SendKeystrokes ( "{ESC}{HOME}" ) ;
1607
+ CheckOuterXml ( original . Replace ( "item" , "xxxxxxx" ) ) ;
1608
+
1609
+ Trace . WriteLine ( "Check compound undo." ) ;
1610
+ Undo ( ) ;
1611
+ w . SendKeystrokes ( "{HOME}" ) ;
1612
+ CheckOuterXml ( original ) ;
1613
+
1614
+ findDialog = OpenReplaceDialog ( ) ;
1615
+
1616
+ // replace all instances of "item" with something shorter "YY";
1617
+ findDialog . Window . SendKeystrokes ( "item{TAB}YY%a" ) ;
1618
+ findDialog . Window . DismissPopUp ( "{ESC}" ) ;
1619
+
1620
+ w . SendKeystrokes ( "{ESC}{HOME}" ) ;
1621
+ CheckOuterXml ( original . Replace ( "item" , "YY" ) ) ;
1622
+
1623
+ Trace . WriteLine ( "Check compound undo." ) ;
1624
+ Undo ( ) ;
1625
+ w . SendKeystrokes ( "{HOME}" ) ;
1626
+ CheckOuterXml ( original ) ;
1627
+ }
1628
+
1587
1629
[ TestMethod ]
1588
1630
[ Timeout ( TestMethodTimeout ) ]
1589
1631
public void TestReplace ( )
@@ -1596,7 +1638,6 @@ public void TestReplace()
1596
1638
1597
1639
w . SendKeystrokes ( "{HOME}" ) ;
1598
1640
var findDialog = OpenReplaceDialog ( ) ;
1599
- findDialog . ClearFindCheckBoxes ( ) ;
1600
1641
1601
1642
Trace . WriteLine ( "Toggle dialog using ctrl+f & ctrl+h" ) ;
1602
1643
findDialog . Window . SendKeystrokes ( "^f" ) ;
@@ -3064,6 +3105,20 @@ void CheckProperties(AutomationWrapper node)
3064
3105
//Trace.WriteLine("\tHelpTopic=" + node.GetHelpTopic(out filename));
3065
3106
}
3066
3107
3108
+ public string GetClipboardText ( )
3109
+ {
3110
+ int retries = 5 ;
3111
+ while ( retries -- > 0 )
3112
+ {
3113
+ if ( Clipboard . ContainsText ( ) )
3114
+ {
3115
+ return Clipboard . GetText ( ) ;
3116
+ }
3117
+ Sleep ( 250 ) ;
3118
+ }
3119
+
3120
+ throw new ApplicationException ( "clipboard does not contain any text!" ) ;
3121
+ }
3067
3122
public override void CheckClipboard ( string expected )
3068
3123
{
3069
3124
int retries = 5 ;
0 commit comments