Java 类javafx.scene.web.WebHistory.Entry 实例源码

项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for simple navigation.
 */
@Test(timeout=10000)
public void testNavigateSimple() {
    initWebEngineOnFXThread();
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertNotNull(entries);
    Assert.assertTrue("Entries list is not empty before navigating", entries.isEmpty());
    Assert.assertEquals(0, currentIndex);
    Assert.assertNull(title);
    loadSite(HistoryResources.getHelloHTML());
    currentIndex = history.getCurrentIndex();
    title = engine.getTitle();
    Assert.assertEquals(1, entries.size());
    Assert.assertEquals(0, currentIndex);
    Assert.assertEquals("0", title);
    loadSite(HistoryResources.getHelloHTML2());
    currentIndex = history.getCurrentIndex();
    title = engine.getTitle();
    Assert.assertEquals(2, entries.size());
    Assert.assertEquals(1, currentIndex);
    Assert.assertEquals("1", title);
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for loading the same page multiple times.
 */
@Test(timeout=10000)
public void testLoadSamePage() {
    initWELoadHelloFXThread();
    doWaitPageLoading();
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(1, entries.size());
    Assert.assertEquals(0, currentIndex);
    Assert.assertEquals("0", title);
    loadSite(HistoryResources.getHelloHTML());
    currentIndex = history.getCurrentIndex();
    title = engine.getTitle();
    Assert.assertEquals(1, entries.size());
    Assert.assertEquals(0, currentIndex);
    Assert.assertEquals("0", title);
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for WebHistory.go() method called with a negative argument when it is impossible to load an entry.
 */
@Test(timeout=10000)
public void testGoBackImpossible() {
    initWebEngineOnFXThread();
    createHistory();
    e = null;
    Platform.runLater(new Runnable() {
        public void run() {
            try {
               history.go(-5);
            } catch (IndexOutOfBoundsException ex) {
                e = ex;
            }
        }
    });
    doWait(exceptionHere);
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(3, entries.size());
    Assert.assertEquals(2, currentIndex);
    Assert.assertEquals("2", title);
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for WebHistory.go() method called with a positive argument when it is impossible to load an entry.
 */
@Test(timeout=10000)
public void testGoForwardImpossible() {
    initWebEngineOnFXThread();
    createHistory();
    e = null;
    Platform.runLater(new Runnable() {
        public void run() {
            try {
               history.go(5);
            } catch (IndexOutOfBoundsException ex) {
                e = ex;
            }
        }
    });
    doWait(exceptionHere);
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(3, entries.size());
    Assert.assertEquals(2, currentIndex);
    Assert.assertEquals("2", title);
}
项目:openjfx-8u-dev-tests    文件:EntryTest.java   
private void getEntry(final int n) {
    doWait(engineReady);
    entry = null;
    Platform.runLater(new Runnable() {
        public void run() {
            List <Entry>l = history.getEntries();
            entry = l.get(n);
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return entry != null;
        }
    });
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for WebHistory.go() method called with a negative argument.
 */
@Test(timeout=10000)
public void testGoBack() {
    initWebEngineOnFXThread();
    createHistory();
    go(-1);
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(3, entries.size());
    Assert.assertEquals(1, currentIndex);
    Assert.assertEquals("1", title);
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for WebHistory.go() method called with a positive argument.
 */
@Test(timeout=10000)
public void testGoForward() {
    initWebEngineOnFXThread();
    createHistory();
    go(-1);
    go(1);
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(3, entries.size());
    Assert.assertEquals(2, currentIndex);
    Assert.assertEquals("2", title);
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for WebHistory.go() method called with 0.
 */
@Test(timeout=10000)
public void testGo0() {
    initWebEngineOnFXThread();
    createHistory();
    go(0);
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(3, entries.size());
    Assert.assertEquals(2, currentIndex);
    Assert.assertEquals("2", title);
}
项目:openjfx-8u-dev-tests    文件:NavigatingTest.java   
/**
 * Test for loading a resource which cannot be loaded.
 */
@Test(timeout=10000)
public void test404() {
    initWebEngineOnFXThread();
    loadSite("file://nothing-here");
    List<Entry> entries = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    String title = engine.getTitle();
    Assert.assertEquals(0, entries.size());
    Assert.assertEquals(0, currentIndex);
    Assert.assertNull(title);
}
项目:mars-sim    文件:BrowserJFX.java   
@SuppressWarnings("restriction")
public String getCurrentURL() {
       //history = engine.getHistory();
       ObservableList<WebHistory.Entry> entryList = history.getEntries();
       int currentIndex = history.getCurrentIndex();
       String txt = null;
       if (currentIndex >=0 ) {
        txt = entryList.get(currentIndex).getUrl();
        //System.out.println("currentIndex is " + currentIndex + " url is " + txt);
        //Platform.runLater(() -> { history.go(0);} );
       }
       return txt;
     }