| 1 |
// Copyright (C) 2023 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick |
| 5 |
import QtTest |
| 6 |
import QtGrpc |
| 7 |
import QmlTestUri |
| 8 |
|
| 9 |
TestCase { |
| 10 |
id: root |
| 11 |
name: "qtgrpcHttp2ChannelTest" |
| 12 |
|
| 13 |
GrpcChannelOptions { |
| 14 |
id: optionsVar |
| 15 |
deadlineTimeout: { 1000 } |
| 16 |
metadata: GrpcMetadata { |
| 17 |
id: grpcData |
| 18 |
data: ({ "user-name": "localhost", |
| 19 |
"user-password": "qwerty"}) |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
GrpcHttp2Channel { |
| 24 |
id: channelId |
| 25 |
hostUri: "http://localhost:50051" |
| 26 |
options: GrpcChannelOptions { |
| 27 |
deadlineTimeout: { 1000 } |
| 28 |
metadata: grpcData |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
GrpcHttp2Channel { |
| 33 |
id: secondChannelId |
| 34 |
hostUri: "http://localhost:50051" |
| 35 |
options: optionsVar |
| 36 |
} |
| 37 |
|
| 38 |
function test_2GrpcTypes_data() { |
| 39 |
return [ |
| 40 |
{ tag: "channelId is an object", |
| 41 |
field: typeof channelId, answer: "object" }, |
| 42 |
{ tag: "secondChannelId is an object", |
| 43 |
field: typeof secondChannelId, answer: "object" }, |
| 44 |
{ tag: "channelId.options is an object", |
| 45 |
field: typeof channelId.options, answer: "object" }, |
| 46 |
{ tag: "optionsVar is an object", |
| 47 |
field: typeof optionsVar, answer: "object" } |
| 48 |
] |
| 49 |
} |
| 50 |
|
| 51 |
function test_2GrpcTypes(data) { |
| 52 |
compare(data.field, data.answer) |
| 53 |
} |
| 54 |
|
| 55 |
function test_3GrpcChannelValues_data() { |
| 56 |
return [ |
| 57 |
{ tag: "channelId Host", |
| 58 |
field: channelId.hostUri, answer: "http://localhost:50051" }, |
| 59 |
{ tag: "channelId deadlineTimeout", |
| 60 |
field: channelId.options.deadlineTimeout, answer: 1000 }, |
| 61 |
{ tag: "channelId metadata", |
| 62 |
field: channelId.options.metadata, answer: grpcData }, |
| 63 |
{ tag: "secondChannelId deadlineTimeout", |
| 64 |
field: secondChannelId.options.deadlineTimeout, answer: 1000 }, |
| 65 |
{ tag: "secondChannelId Host", |
| 66 |
field: secondChannelId.hostUri, answer: "http://localhost:50051" }, |
| 67 |
{ tag: "secondChannelId metadata", |
| 68 |
field: secondChannelId.options.metadata, answer: grpcData }, |
| 69 |
{ tag: "secondChannelId metadata == channelId metadata", |
| 70 |
field: secondChannelId.options.metadata, |
| 71 |
answer: channelId.options.metadata } |
| 72 |
] |
| 73 |
} |
| 74 |
|
| 75 |
function test_3GrpcChannelValues(data) { |
| 76 |
compare(data.field, data.answer) |
| 77 |
} |
| 78 |
} |