forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathTestFrameTest.java
More file actions
63 lines (50 loc) · 1.92 KB
/
TestFrameTest.java
File metadata and controls
63 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
package tests.junittests;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.cef.browser.CefBrowser;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
// Test the TestFrame implementation.
@ExtendWith(TestSetupExtension.class)
class TestFrameTest {
private boolean gotSetupTest_ = false;
private boolean gotCleanupTest_ = false;
private boolean gotLoadingStateChange_ = false;
@Test
void minimal() {
final String testUrl = "http://test.com/test.html";
TestFrame frame = new TestFrame() {
@Override
protected void setupTest() {
assertFalse(gotSetupTest_);
gotSetupTest_ = true;
addResource(testUrl, "<html><body>Test!</body></html>", "text/html");
createBrowser(testUrl);
super.setupTest();
}
@Override
protected void cleanupTest() {
assertFalse(gotCleanupTest_);
gotCleanupTest_ = true;
super.cleanupTest();
}
@Override
public void onLoadingStateChange(CefBrowser browser, boolean isLoading,
boolean canGoBack, boolean canGoForward) {
if (!isLoading) {
assertFalse(gotLoadingStateChange_);
gotLoadingStateChange_ = true;
terminateTest();
}
}
};
frame.awaitCompletion();
assertTrue(gotSetupTest_);
assertTrue(gotLoadingStateChange_);
assertTrue(gotCleanupTest_);
}
}