MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / InputAtomsTest

Class InputAtomsTest

java/test/org/openqa/selenium/atoms/InputAtomsTest.java:30–81  ·  view source on GitHub ↗

Sanity tests against the //javascript/webdriver/atoms:inputs target.

Source from the content-addressed store, hash-verified

28
29/** Sanity tests against the //javascript/webdriver/atoms:inputs target. */
30class InputAtomsTest {
31
32 private static final String RESOURCE_PATH = "/org/openqa/selenium/atoms/atoms_inputs.js";
33
34 @Test
35 void exportsTheExpectedNames() throws IOException {
36 final String source = JavaScriptLoader.loadResource(RESOURCE_PATH);
37 ContextFactory.getGlobal()
38 .call(
39 new ContextAction<>() {
40 private TopLevel global;
41
42 @Override
43 public Object run(Context context) {
44 global = context.initStandardObjects();
45
46 // Check assumptions abut the global context, which the atoms assume is a DOM
47 // window.
48 assertThat(eval(context, "this.window=this;")).isEqualTo(global);
49 assertThat(eval(context, "this")).isEqualTo(global);
50 assertThat(eval(context, "window")).isEqualTo(global);
51 assertThat(eval(context, "this === window")).isEqualTo(true);
52
53 eval(context, source, RESOURCE_PATH);
54
55 assertFunction(context, "webdriver.atoms.inputs.sendKeys");
56 assertFunction(context, "webdriver.atoms.inputs.click");
57 assertFunction(context, "webdriver.atoms.inputs.mouseMove");
58 assertFunction(context, "webdriver.atoms.inputs.mouseButtonDown");
59 assertFunction(context, "webdriver.atoms.inputs.mouseButtonUp");
60 assertFunction(context, "webdriver.atoms.inputs.doubleClick");
61 assertFunction(context, "webdriver.atoms.inputs.rightClick");
62
63 return null;
64 }
65
66 private void assertFunction(Context context, String property) {
67 assertThat(eval(context, "typeof " + property))
68 .describedAs(property)
69 .isEqualTo("function");
70 }
71
72 private Object eval(Context context, String script) {
73 return eval(context, script, "");
74 }
75
76 private Object eval(Context context, String script, String src) {
77 return context.evaluateString(global, script, src, 1, null);
78 }
79 });
80 }
81}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected