1fb726d48Sopenharmony_ci/*
2fb726d48Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3fb726d48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb726d48Sopenharmony_ci * you may not use this file except in compliance with the License.
5fb726d48Sopenharmony_ci * You may obtain a copy of the License at
6fb726d48Sopenharmony_ci *
7fb726d48Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fb726d48Sopenharmony_ci *
9fb726d48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb726d48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb726d48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb726d48Sopenharmony_ci * See the License for the specific language governing permissions and
13fb726d48Sopenharmony_ci * limitations under the License.
14fb726d48Sopenharmony_ci */
15fb726d48Sopenharmony_ci
16fb726d48Sopenharmony_ciimport { Serialize } from '../../../src/hdc/common/Serialize';
17fb726d48Sopenharmony_ci
18fb726d48Sopenharmony_cidescribe('Serialize Test', () => {
19fb726d48Sopenharmony_ci  it('Serialize Test01', function () {
20fb726d48Sopenharmony_ci    let banne = {
21fb726d48Sopenharmony_ci      banner: 1,
22fb726d48Sopenharmony_ci      authType: 1,
23fb726d48Sopenharmony_ci      sessionId: 1,
24fb726d48Sopenharmony_ci      connectKey: 1,
25fb726d48Sopenharmony_ci      buf: '',
26fb726d48Sopenharmony_ci    };
27fb726d48Sopenharmony_ci    expect(Serialize.serializeSessionHandShake(banne)).not.toBeUndefined();
28fb726d48Sopenharmony_ci  });
29fb726d48Sopenharmony_ci  it('Serialize Test02', function () {
30fb726d48Sopenharmony_ci    let payloadProtect = {
31fb726d48Sopenharmony_ci      channelId: 1,
32fb726d48Sopenharmony_ci      commandFlag: 1,
33fb726d48Sopenharmony_ci      checkSum: 1,
34fb726d48Sopenharmony_ci      vCode: 1,
35fb726d48Sopenharmony_ci    };
36fb726d48Sopenharmony_ci    expect(Serialize.serializePayloadProtect(payloadProtect)).not.toBeUndefined();
37fb726d48Sopenharmony_ci  });
38fb726d48Sopenharmony_ci  it('Serialize Test03', function () {
39fb726d48Sopenharmony_ci    let transferConfig = {
40fb726d48Sopenharmony_ci      fileSize: 1,
41fb726d48Sopenharmony_ci      atime: 1,
42fb726d48Sopenharmony_ci      mtime: 1,
43fb726d48Sopenharmony_ci      options: 1,
44fb726d48Sopenharmony_ci      path: 1,
45fb726d48Sopenharmony_ci      optionalName: 1,
46fb726d48Sopenharmony_ci      updateIfNew: 1,
47fb726d48Sopenharmony_ci      compressType: 1,
48fb726d48Sopenharmony_ci      holdTimestamp: 1,
49fb726d48Sopenharmony_ci      functionName: 1,
50fb726d48Sopenharmony_ci      clientCwd: 1,
51fb726d48Sopenharmony_ci      reserve1: 1,
52fb726d48Sopenharmony_ci      reserve2: 1,
53fb726d48Sopenharmony_ci    };
54fb726d48Sopenharmony_ci    expect(Serialize.serializeTransferConfig(transferConfig)).not.toBeUndefined();
55fb726d48Sopenharmony_ci  });
56fb726d48Sopenharmony_ci  it('Serialize Test04', function () {
57fb726d48Sopenharmony_ci    let transferPayload = {
58fb726d48Sopenharmony_ci      index: 1,
59fb726d48Sopenharmony_ci      compressType: 1,
60fb726d48Sopenharmony_ci      compressSize: 1,
61fb726d48Sopenharmony_ci      uncompressSize: 1,
62fb726d48Sopenharmony_ci    };
63fb726d48Sopenharmony_ci    expect(Serialize.serializeTransferPayload(transferPayload)).not.toBeUndefined();
64fb726d48Sopenharmony_ci  });
65fb726d48Sopenharmony_ci  it('Serialize Test06', function () {
66fb726d48Sopenharmony_ci    let data = {
67fb726d48Sopenharmony_ci      buffer: 1,
68fb726d48Sopenharmony_ci    };
69fb726d48Sopenharmony_ci    // @ts-ignore
70fb726d48Sopenharmony_ci    let uint8Array = new Uint8Array(data);
71fb726d48Sopenharmony_ci    let dataBuffer = uint8Array.buffer;
72fb726d48Sopenharmony_ci    expect(Serialize.parseTransferConfig(data)).not.toBeUndefined();
73fb726d48Sopenharmony_ci  });
74fb726d48Sopenharmony_ci  it('Serialize Test05', function () {
75fb726d48Sopenharmony_ci    let tagKey = 1;
76fb726d48Sopenharmony_ci    expect(Serialize.readTagWireType(tagKey)).not.toBeUndefined();
77fb726d48Sopenharmony_ci  });
78fb726d48Sopenharmony_ci  it('Serialize Test07', function () {
79fb726d48Sopenharmony_ci    let data = {
80fb726d48Sopenharmony_ci      buffer: 1,
81fb726d48Sopenharmony_ci    };
82fb726d48Sopenharmony_ci    // @ts-ignore
83fb726d48Sopenharmony_ci    let uint8Array = new Uint8Array(data);
84fb726d48Sopenharmony_ci    let dataBuffer = uint8Array.buffer;
85fb726d48Sopenharmony_ci    expect(Serialize.parsePayloadProtect(data)).not.toBeUndefined();
86fb726d48Sopenharmony_ci  });
87fb726d48Sopenharmony_ci
88fb726d48Sopenharmony_ci  it('Serialize Test08', function () {
89fb726d48Sopenharmony_ci    expect(Serialize.writeVarIntU64(100_000_000)).not.toBeUndefined();
90fb726d48Sopenharmony_ci  });
91fb726d48Sopenharmony_ci
92fb726d48Sopenharmony_ci  it('Serialize Test09', function () {
93fb726d48Sopenharmony_ci    let data = {
94fb726d48Sopenharmony_ci      buffer: 1,
95fb726d48Sopenharmony_ci    };
96fb726d48Sopenharmony_ci    // @ts-ignore
97fb726d48Sopenharmony_ci    let uint8Array = new Uint8Array(data);
98fb726d48Sopenharmony_ci    expect(Serialize.parseString(uint8Array, 1)).not.toBeUndefined();
99fb726d48Sopenharmony_ci  });
100fb726d48Sopenharmony_ci
101fb726d48Sopenharmony_ci  it('Serialize Test10', function () {
102fb726d48Sopenharmony_ci    let data = {
103fb726d48Sopenharmony_ci      buffer: 1,
104fb726d48Sopenharmony_ci    };
105fb726d48Sopenharmony_ci    // @ts-ignore
106fb726d48Sopenharmony_ci    let uint8Array = new Uint8Array(data);
107fb726d48Sopenharmony_ci    expect(Serialize.parseHandshake(uint8Array)).toEqual({
108fb726d48Sopenharmony_ci      _authType: -1,
109fb726d48Sopenharmony_ci      _banner: '',
110fb726d48Sopenharmony_ci      _buf: '',
111fb726d48Sopenharmony_ci      _connectKey: '',
112fb726d48Sopenharmony_ci      _sessionId: -1,
113fb726d48Sopenharmony_ci      _version: '',
114fb726d48Sopenharmony_ci    });
115fb726d48Sopenharmony_ci  });
116fb726d48Sopenharmony_ci
117fb726d48Sopenharmony_ci  it('Serialize Test11', function () {
118fb726d48Sopenharmony_ci    expect(Serialize.writeVarIntU32(100_000_000)).not.toBeUndefined();
119fb726d48Sopenharmony_ci  });
120fb726d48Sopenharmony_ci});
121