@appium/fake-driver 6.1.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/build/lib/command-maps/execute-method-map.d.ts +22 -0
  2. package/build/lib/command-maps/execute-method-map.d.ts.map +1 -0
  3. package/build/lib/command-maps/execute-method-map.js +20 -0
  4. package/build/lib/command-maps/execute-method-map.js.map +1 -0
  5. package/build/lib/command-maps/new-bidi-commands.d.ts +26 -0
  6. package/build/lib/command-maps/new-bidi-commands.d.ts.map +1 -0
  7. package/build/lib/command-maps/new-bidi-commands.js +29 -0
  8. package/build/lib/command-maps/new-bidi-commands.js.map +1 -0
  9. package/build/lib/command-maps/new-method-map.d.ts +30 -0
  10. package/build/lib/command-maps/new-method-map.d.ts.map +1 -0
  11. package/build/lib/command-maps/new-method-map.js +19 -0
  12. package/build/lib/command-maps/new-method-map.js.map +1 -0
  13. package/build/lib/commands/alert.d.ts +3 -0
  14. package/build/lib/commands/alert.d.ts.map +1 -1
  15. package/build/lib/commands/alert.js +3 -0
  16. package/build/lib/commands/alert.js.map +1 -1
  17. package/build/lib/commands/contexts.d.ts +4 -0
  18. package/build/lib/commands/contexts.d.ts.map +1 -1
  19. package/build/lib/commands/contexts.js +4 -0
  20. package/build/lib/commands/contexts.js.map +1 -1
  21. package/build/lib/commands/element.d.ts +14 -0
  22. package/build/lib/commands/element.d.ts.map +1 -1
  23. package/build/lib/commands/element.js +14 -0
  24. package/build/lib/commands/element.js.map +1 -1
  25. package/build/lib/commands/find.d.ts +6 -0
  26. package/build/lib/commands/find.d.ts.map +1 -1
  27. package/build/lib/commands/find.js +5 -0
  28. package/build/lib/commands/find.js.map +1 -1
  29. package/build/lib/commands/general.d.ts +15 -0
  30. package/build/lib/commands/general.d.ts.map +1 -1
  31. package/build/lib/commands/general.js +15 -0
  32. package/build/lib/commands/general.js.map +1 -1
  33. package/build/lib/driver.d.ts +84 -84
  34. package/build/lib/driver.d.ts.map +1 -1
  35. package/build/lib/driver.js +27 -77
  36. package/build/lib/driver.js.map +1 -1
  37. package/build/lib/fake-app.d.ts +4 -4
  38. package/build/lib/fake-app.d.ts.map +1 -1
  39. package/build/lib/fake-app.js +13 -13
  40. package/build/lib/fake-app.js.map +1 -1
  41. package/build/lib/fake-element.d.ts +2 -2
  42. package/build/lib/fake-element.d.ts.map +1 -1
  43. package/build/lib/fake-element.js +14 -14
  44. package/build/lib/fake-element.js.map +1 -1
  45. package/build/lib/index.d.ts +1 -0
  46. package/build/lib/index.d.ts.map +1 -1
  47. package/build/lib/index.js +1 -0
  48. package/build/lib/index.js.map +1 -1
  49. package/lib/command-maps/execute-method-map.ts +19 -0
  50. package/lib/command-maps/new-bidi-commands.ts +27 -0
  51. package/lib/command-maps/new-method-map.ts +18 -0
  52. package/lib/commands/alert.ts +3 -0
  53. package/lib/commands/contexts.ts +4 -0
  54. package/lib/commands/element.ts +14 -0
  55. package/lib/commands/find.ts +7 -0
  56. package/lib/commands/general.ts +15 -0
  57. package/lib/driver.ts +36 -87
  58. package/lib/fake-app.ts +16 -16
  59. package/lib/fake-element.ts +20 -20
  60. package/lib/index.ts +1 -0
  61. package/package.json +3 -3
  62. package/tsconfig.json +4 -0
package/lib/fake-app.ts CHANGED
@@ -24,11 +24,11 @@ export class FakeApp {
24
24
  activeAlert: FakeElement | null;
25
25
  lat: number;
26
26
  long: number;
27
- private _width: number | null;
28
- private _height: number | null;
29
27
  rawXml: string;
30
28
  currentOrientation: Orientation;
31
29
  actionLog: ActionSequence[][];
30
+ private _width: number | null;
31
+ private _height: number | null;
32
32
 
33
33
  constructor() {
34
34
  this.dom = null;
@@ -66,10 +66,6 @@ export class FakeApp {
66
66
  return this.currentOrientation;
67
67
  }
68
68
 
69
- set orientation(o: Orientation) {
70
- this.currentOrientation = o;
71
- }
72
-
73
69
  get width(): number {
74
70
  if (this._width === null) {
75
71
  this.setDims();
@@ -92,16 +88,8 @@ export class FakeApp {
92
88
  return h;
93
89
  }
94
90
 
95
- private setDims(): void {
96
- const nodes = this.xpathQuery('//app');
97
- if (!_.isArray(nodes)) {
98
- throw new Error(
99
- 'Cannot fetch app dimensions because no corresponding node has been found in the source'
100
- );
101
- }
102
- const app = new FakeElement(nodes[0] as unknown as XmlNodeLike, this);
103
- this._width = parseInt(app.nodeAttrs.width, 10);
104
- this._height = parseInt(app.nodeAttrs.height, 10);
91
+ set orientation(o: Orientation) {
92
+ this.currentOrientation = o;
105
93
  }
106
94
 
107
95
  async loadApp(appPath: string): Promise<void> {
@@ -224,6 +212,18 @@ export class FakeApp {
224
212
  getScreenshot(): string {
225
213
  return readFileSync(SCREENSHOT, 'base64');
226
214
  }
215
+
216
+ private setDims(): void {
217
+ const nodes = this.xpathQuery('//app');
218
+ if (!_.isArray(nodes)) {
219
+ throw new Error(
220
+ 'Cannot fetch app dimensions because no corresponding node has been found in the source'
221
+ );
222
+ }
223
+ const app = new FakeElement(nodes[0] as unknown as XmlNodeLike, this);
224
+ this._width = parseInt(app.nodeAttrs.width, 10);
225
+ this._height = parseInt(app.nodeAttrs.height, 10);
226
+ }
227
227
  }
228
228
 
229
229
  export class FakeWebViewImpl implements FakeWebView {
@@ -38,22 +38,20 @@ export class FakeElement {
38
38
  this.parseCss();
39
39
  }
40
40
 
41
- private parseCss(): void {
42
- if (this.nodeAttrs.style) {
43
- const segments = this.nodeAttrs.style.split(';');
44
- for (const s of segments) {
45
- let [prop, val] = s.split(':');
46
- prop = prop.trim();
47
- val = val.trim();
48
- this.css[prop] = val;
49
- }
50
- }
51
- }
52
-
53
41
  get tagName(): string {
54
42
  return this.node.tagName;
55
43
  }
56
44
 
45
+ get xmlFragment(): XMLDocument {
46
+ const frag = new XMLDom.XMLSerializer().serializeToString(
47
+ this.node as unknown as XMLNode
48
+ );
49
+ return new XMLDom.DOMParser().parseFromString(
50
+ frag,
51
+ XMLDom.MIME_TYPE.XML_TEXT
52
+ ) as XMLDocument;
53
+ }
54
+
57
55
  setAttr(k: string, v: string): void {
58
56
  this.attrs[k] = v;
59
57
  }
@@ -116,13 +114,15 @@ export class FakeElement {
116
114
  return null;
117
115
  }
118
116
 
119
- get xmlFragment(): XMLDocument {
120
- const frag = new XMLDom.XMLSerializer().serializeToString(
121
- this.node as unknown as XMLNode
122
- );
123
- return new XMLDom.DOMParser().parseFromString(
124
- frag,
125
- XMLDom.MIME_TYPE.XML_TEXT
126
- ) as XMLDocument;
117
+ private parseCss(): void {
118
+ if (this.nodeAttrs.style) {
119
+ const segments = this.nodeAttrs.style.split(';');
120
+ for (const s of segments) {
121
+ let [prop, val] = s.split(':');
122
+ prop = prop.trim();
123
+ val = val.trim();
124
+ this.css[prop] = val;
125
+ }
126
+ }
127
127
  }
128
128
  }
package/lib/index.ts CHANGED
@@ -4,6 +4,7 @@ import {startServer} from './server';
4
4
  const DEFAULT_HOST = 'localhost';
5
5
  const DEFAULT_PORT = 4774;
6
6
 
7
+ /** main. */
7
8
  export async function main() {
8
9
  const getArgValue = (argName: string): string | null => {
9
10
  const argIndex = process.argv.indexOf(argName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/fake-driver",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
4
4
  "description": "Mock driver used internally by Appium for testing. Ignore",
5
5
  "keywords": [
6
6
  "automation",
@@ -40,7 +40,7 @@
40
40
  "test:unit": "mocha --exit --timeout 10s --slow 5s \"./test/unit/**/*.spec.ts\""
41
41
  },
42
42
  "dependencies": {
43
- "@xmldom/xmldom": "0.9.9",
43
+ "@xmldom/xmldom": "0.9.10",
44
44
  "asyncbox": "6.1.0",
45
45
  "lodash": "4.18.1",
46
46
  "xpath": "0.0.34"
@@ -78,5 +78,5 @@
78
78
  },
79
79
  "main": "./build/lib/index.js",
80
80
  "types": "./build/lib/index.d.ts",
81
- "gitHead": "7a8965f5c30ffec2ad04ce75903b3960537cef06"
81
+ "gitHead": "17f84265d10944fec06ae7684ae8ad77d1224b50"
82
82
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": "@appium/tsconfig/tsconfig.json",
3
+ "ts-node": {
4
+ "transpileOnly": true
5
+ },
3
6
  "compilerOptions": {
7
+ "rootDir": ".",
4
8
  "outDir": "build",
5
9
  "checkJs": true,
6
10
  "types": ["mocha", "chai", "chai-as-promised", "node"],