@@ -518,75 +518,6 @@ public void changing(LocationEvent event) {
518518 for (int i = 0 ; i < 100 ; i ++) browser .removeLocationListener (listener );
519519}
520520
521- @ Test
522- public void test_isLocationForCustomText_setUrlAfterDisposedThrowsSwtException () {
523- Browser testBrowser = createBrowser (shell , SWT .NONE );
524- testBrowser .dispose ();
525- assertThrows (SWTException .class , () -> testBrowser .isLocationForCustomText ("about:blank" ));
526- }
527-
528- @ Test
529- public void test_isLocationForCustomText_isSetUrlNotCustomTextUrlAfterSetText () {
530- String url = getValidUrl ();
531- AtomicBoolean locationChanged = new AtomicBoolean (false );
532- browser .addLocationListener (changedAdapter (event -> {
533- locationChanged .set (true );
534- }));
535-
536- browser .setText ("Custom text" );
537- assertTrue ("Time Out: The Browser didn't navigate to the URL" , waitForPassCondition (locationChanged ::get ));
538- locationChanged .set (false );
539- browser .setUrl (url );
540- assertTrue ("Time Out: The Browser didn't navigate to the URL" , waitForPassCondition (locationChanged ::get ));
541- assertFalse ("The navigated URL is falsly indicated to be the custom text URL" , browser .isLocationForCustomText (browser .getUrl ()));
542- }
543-
544- @ Test
545- public void test_isLocationForCustomText_isFirstSetTextURLStillCustomTextUrlAfterSetUrl () {
546- AtomicBoolean locationChanged = new AtomicBoolean (false );
547- browser .addLocationListener (changedAdapter (event -> locationChanged .set (true )));
548- String url = getValidUrl ();
549- browser .setText ("Custom text" );
550- assertTrue (waitForPassCondition (locationChanged ::get ));
551- String firstUrl = browser .getUrl ();
552- locationChanged .set (false );
553- browser .setUrl (url );
554- assertTrue ("Time Out: The Browser didn't navigate to the URL" , waitForPassCondition (locationChanged ::get ));
555- assertTrue (browser .isLocationForCustomText (firstUrl ));
556- assertFalse (browser .isLocationForCustomText (browser .getUrl ()));
557- }
558-
559- private String getValidUrl () {
560- String pluginPath = System .getProperty ("PLUGIN_PATH" );
561- testLogAppend ("PLUGIN_PATH: " + pluginPath );
562- // When test is run via Ant, URL needs to be acquired differently. In that case the PLUGIN_PATH property is set and used.
563- if (pluginPath != null ) {
564- return pluginPath + "/data/testWebsiteWithTitle.html" ;
565- } else {
566- // used when ran from Eclipse gui.
567- return Test_org_eclipse_swt_browser_Browser .class .getClassLoader ().getResource ("testWebsiteWithTitle.html" ).toString ();
568- }
569- }
570-
571- @ Test
572- public void test_isLocationForCustomText_isSetUrlNotCustomTextUrl () {
573- AtomicBoolean locationChanged = new AtomicBoolean (false );
574- browser .addLocationListener (changedAdapter (event -> locationChanged .set (true )));
575- String url = getValidUrl ();
576- browser .setUrl (url );
577- waitForPassCondition (locationChanged ::get );
578- assertFalse ("Url is wrongly considered Custom Text Url" , browser .isLocationForCustomText (browser .getUrl ()));
579- }
580-
581- @ Test
582- public void test_isLocationForCustomText () {
583- AtomicBoolean locationChanged = new AtomicBoolean (false );
584- browser .addLocationListener (changedAdapter (e -> locationChanged .set (true )));
585- browser .setText ("Hello world" );
586- assertTrue ("Timeout: LocationListener.changing() event was never fired" , waitForPassCondition (locationChanged ::get ));
587- assertTrue ("Custom Text URI was not loaded on setText" , browser .isLocationForCustomText (browser .getUrl ()));
588- }
589-
590521@ Test
591522public void test_LocationListener_changing () {
592523 AtomicBoolean changingFired = new AtomicBoolean (false );
@@ -762,9 +693,20 @@ public void test_LocationListener_LocationListener_ordered_changing () {
762693 String url = getValidUrl ();
763694 browser .setUrl (url );
764695 waitForPassCondition (() -> locations .size () == 2 );
765- assertTrue ("Change of locations do not fire in order." , browser . isLocationForCustomText ( locations .get (0 )) && locations .get (1 ).contains ("testWebsiteWithTitle.html" ));
696+ assertTrue ("Change of locations do not fire in order." , locations .get (0 ). equals ( "about:blank" ) && locations .get (1 ).contains ("testWebsiteWithTitle.html" ));
766697}
767698
699+ private String getValidUrl () {
700+ String pluginPath = System .getProperty ("PLUGIN_PATH" );
701+ testLogAppend ("PLUGIN_PATH: " + pluginPath );
702+ // When test is run via Ant, URL needs to be acquired differently. In that case the PLUGIN_PATH property is set and used.
703+ if (pluginPath != null ) {
704+ return pluginPath + "/data/testWebsiteWithTitle.html" ;
705+ } else {
706+ // used when ran from Eclipse gui.
707+ return Test_org_eclipse_swt_browser_Browser .class .getClassLoader ().getResource ("testWebsiteWithTitle.html" ).toString ();
708+ }
709+ }
768710
769711@ Test
770712/** Ensue that only one changed and one completed event are fired for url changes */
0 commit comments