mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-02 17:29:17 +02:00
fix(scrcpy): options.setListDisplays
not work for some versions
fixes #567
This commit is contained in:
parent
7056feb3b1
commit
b3db76b96a
10 changed files with 126 additions and 2 deletions
2
.prettierrc.yaml
Normal file
2
.prettierrc.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
trailingComma: all
|
||||
tabWidth: 4
|
|
@ -1,5 +1,6 @@
|
|||
export * from "./1_16.js";
|
||||
export * from "./1_22.js";
|
||||
export * from "./2_0.js";
|
||||
export * from "./2_1.js";
|
||||
export * from "./latest.js";
|
||||
export * from "./types.js";
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { AdbScrcpyOptions2_0 } from "./2_0.js";
|
||||
import { AdbScrcpyOptions2_1 } from "./2_1.js";
|
||||
|
||||
export class AdbScrcpyOptionsLatest extends AdbScrcpyOptions2_0 {}
|
||||
export class AdbScrcpyOptionsLatest extends AdbScrcpyOptions2_1 {}
|
||||
|
|
|
@ -22,4 +22,12 @@ describe("ScrcpyOptions1_16", () => {
|
|||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setListDisplays", () => {
|
||||
it("should set `display` to `-1`", () => {
|
||||
const options = new ScrcpyOptions1_16({});
|
||||
options.setListDisplays();
|
||||
expect(options.value.displayId).toBe(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
26
libraries/scrcpy/src/options/1_17.spec.ts
Normal file
26
libraries/scrcpy/src/options/1_17.spec.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { describe, expect, it } from "@jest/globals";
|
||||
|
||||
import { ScrcpyOptions1_17 } from "./1_17.js";
|
||||
|
||||
describe("ScrcpyOptions1_17", () => {
|
||||
it("should share `value` with `base`", () => {
|
||||
const options = new ScrcpyOptions1_17({});
|
||||
expect(options.value).toBe(options["_base"].value);
|
||||
});
|
||||
|
||||
describe("setListDisplays", () => {
|
||||
it("should set `displayId` to `-1`", () => {
|
||||
const options = new ScrcpyOptions1_17({});
|
||||
options.setListDisplays();
|
||||
expect(options.value.displayId).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setListEncoders", () => {
|
||||
it("should set `encoderName` to `_`", () => {
|
||||
const options = new ScrcpyOptions1_17({});
|
||||
options.setListEncoders();
|
||||
expect(options.value.encoderName).toBe("_");
|
||||
});
|
||||
});
|
||||
});
|
26
libraries/scrcpy/src/options/1_18.spec.ts
Normal file
26
libraries/scrcpy/src/options/1_18.spec.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { describe, expect, it } from "@jest/globals";
|
||||
|
||||
import { ScrcpyOptions1_18 } from "./1_18.js";
|
||||
|
||||
describe("ScrcpyOptions1_18", () => {
|
||||
it("should share `value` with `base`", () => {
|
||||
const options = new ScrcpyOptions1_18({});
|
||||
expect(options.value).toBe(options["_base"].value);
|
||||
});
|
||||
|
||||
describe("setListDisplays", () => {
|
||||
it("should set `displayId` to `-1`", () => {
|
||||
const options = new ScrcpyOptions1_18({});
|
||||
options.setListDisplays();
|
||||
expect(options.value.displayId).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setListEncoders", () => {
|
||||
it("should set `encoderName` to `_`", () => {
|
||||
const options = new ScrcpyOptions1_18({});
|
||||
options.setListEncoders();
|
||||
expect(options.value.encoderName).toBe("_");
|
||||
});
|
||||
});
|
||||
});
|
|
@ -14,4 +14,12 @@ describe("ScrcpyOptions1_25", () => {
|
|||
).createScrollController();
|
||||
expect(controller1_25).not.toBe(controller1_24);
|
||||
});
|
||||
|
||||
describe("setListDisplays", () => {
|
||||
it("should set `display` to `-1`", () => {
|
||||
const options = new ScrcpyOptions1_25({});
|
||||
options.setListDisplays();
|
||||
expect(options.value.displayId).toBe(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
21
libraries/scrcpy/src/options/2.0.spec.ts
Normal file
21
libraries/scrcpy/src/options/2.0.spec.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { describe, expect, it } from "@jest/globals";
|
||||
|
||||
import { ScrcpyOptions2_0 } from "./2_0.js";
|
||||
|
||||
describe("ScrcpyOptions2_0", () => {
|
||||
describe("setListDisplays", () => {
|
||||
it("should set `listDisplays` to `true`", () => {
|
||||
const options = new ScrcpyOptions2_0({});
|
||||
options.setListDisplays();
|
||||
expect(options.value.listDisplays).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setListEncoders", () => {
|
||||
it("should set `listEncoders` to `true`", () => {
|
||||
const options = new ScrcpyOptions2_0({});
|
||||
options.setListEncoders();
|
||||
expect(options.value.listEncoders).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
21
libraries/scrcpy/src/options/2.1.spec.ts
Normal file
21
libraries/scrcpy/src/options/2.1.spec.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { describe, expect, it } from "@jest/globals";
|
||||
|
||||
import { ScrcpyOptions2_1 } from "./2_1.js";
|
||||
|
||||
describe("ScrcpyOptions2_1", () => {
|
||||
describe("setListDisplays", () => {
|
||||
it("should set `listDisplays` to `true`", () => {
|
||||
const options = new ScrcpyOptions2_1({});
|
||||
options.setListDisplays();
|
||||
expect(options.value.listDisplays).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setListEncoders", () => {
|
||||
it("should set `listEncoders` to `true`", () => {
|
||||
const options = new ScrcpyOptions2_1({});
|
||||
options.setListEncoders();
|
||||
expect(options.value.listEncoders).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -141,6 +141,17 @@ export abstract class ScrcpyOptionsBase<
|
|||
constructor(base: B, value: Required<T>) {
|
||||
this._base = base;
|
||||
this.value = value;
|
||||
this.#setValue();
|
||||
}
|
||||
|
||||
#setValue() {
|
||||
// Share `value` with `_base` class,
|
||||
// so updating `_base.value` in `_base.setListEncoders()`/
|
||||
// `_base.setListDisplays()` will also update `this.value`.
|
||||
Object.assign(this._base, { value: this.value });
|
||||
if (this._base instanceof ScrcpyOptionsBase) {
|
||||
this._base.#setValue();
|
||||
}
|
||||
}
|
||||
|
||||
abstract serialize(): string[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue