From cfe55b55f765e31cf8f970598b3262ededa022d0 Mon Sep 17 00:00:00 2001 From: voluntas Date: Wed, 25 Dec 2024 18:20:29 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/tests/helper.ts | 13 -- examples/tests/message_header.spec.ts | 184 ---------------- examples/tests/messaging.spec.ts | 197 ------------------ examples/tests/sendonly_audio.spec.ts | 75 ------- examples/tests/sendonly_recvonly.spec.ts | 125 ----------- examples/tests/sendrecv.spec.ts | 135 ------------ examples/tests/simulcast.spec.ts | 78 ------- .../tests/spotlight_sendonly_recvonly.spec.ts | 34 --- examples/tests/spotlight_sendrecv.spec.ts | 25 --- examples/tests/type_close.spec.ts | 60 ------ examples/tests/type_switched.spec.ts | 56 ----- examples/tests/whip_whep.spec.ts | 42 ---- 12 files changed, 1024 deletions(-) delete mode 100644 examples/tests/helper.ts delete mode 100644 examples/tests/message_header.spec.ts delete mode 100644 examples/tests/messaging.spec.ts delete mode 100644 examples/tests/sendonly_audio.spec.ts delete mode 100644 examples/tests/sendonly_recvonly.spec.ts delete mode 100644 examples/tests/sendrecv.spec.ts delete mode 100644 examples/tests/simulcast.spec.ts delete mode 100644 examples/tests/spotlight_sendonly_recvonly.spec.ts delete mode 100644 examples/tests/spotlight_sendrecv.spec.ts delete mode 100644 examples/tests/type_close.spec.ts delete mode 100644 examples/tests/type_switched.spec.ts delete mode 100644 examples/tests/whip_whep.spec.ts diff --git a/examples/tests/helper.ts b/examples/tests/helper.ts deleted file mode 100644 index db9a229f..00000000 --- a/examples/tests/helper.ts +++ /dev/null @@ -1,13 +0,0 @@ -// バージョン比較用のヘルパー関数を追加 -export const isVersionGreaterThanOrEqual = (packageVersion: string, version: string): boolean => { - const v1Parts = packageVersion.split('.').map(Number) - const v2Parts = version.split('.').map(Number) - - for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { - const v1 = v1Parts[i] || 0 - const v2 = v2Parts[i] || 0 - if (v1 > v2) return true - if (v1 < v2) return false - } - return true -} diff --git a/examples/tests/message_header.spec.ts b/examples/tests/message_header.spec.ts deleted file mode 100644 index bf18ea9b..00000000 --- a/examples/tests/message_header.spec.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { expect, test } from '@playwright/test' -import { isVersionGreaterThanOrEqual } from './helper' - -test('messaging pages with header', async ({ browser }) => { - // 新しいページを2つ作成 - const page1 = await browser.newPage() - const page2 = await browser.newPage() - - // それぞれのページに対して操作を行う - await page1.goto('http://localhost:9000/messaging/') - await page2.goto('http://localhost:9000/messaging/') - - // sora js sdk のバージョンを取得する - await page1.waitForSelector('#sora-js-sdk-version') - const page1SoraJsSdkVersion = await page1.$eval('#sora-js-sdk-version', (el) => el.textContent) - if (page1SoraJsSdkVersion === null) { - throw new Error('page1SoraJsSdkVersion is null') - } - // sora-js-sdk のバージョンが 2024.2.0 以上であるか確認して、2024.2.0 未満の場合はテストをスキップする - test.skip( - !isVersionGreaterThanOrEqual(page1SoraJsSdkVersion, '2024.2.0'), - 'sora-js-sdk のバージョンが 2024.2.0 以上である必要があります', - ) - - // チャネル名を設定する - await page1.fill('input[name="channel-name"]', 'message-header') - await page2.fill('input[name="channel-name"]', 'message-header') - - // header を有効にする - await page1.check('#check-header') - await page2.check('#check-header') - - // connect ボタンを押して接続開始 - await page1.click('#connect') - await page2.click('#connect') - - await page1.waitForSelector('#connection-id:not(:empty)') - const page1ConnectionId = await page1.$eval('#connection-id', (el) => el.textContent) - console.log(`page1 connectionId=${page1ConnectionId}`) - - await page2.waitForSelector('#connection-id:not(:empty)') - const page2ConnectionId = await page2.$eval('#connection-id', (el) => el.textContent) - console.log(`page2 connectionId=${page2ConnectionId}`) - - // page1 で #example の DataChannel が open したことを確認 - await page1.waitForSelector('#messaging li', { state: 'attached' }) - - // page2 で #example の DataChannel が open したことを確認 - await page2.waitForSelector('#messaging li', { state: 'attached' }) - - // page1からpage2へメッセージを送信 - const page1Message = 'Hello from page1' - await page1.fill('input[name="message"]', page1Message) - await page1.click('#send-message') - - // page2でメッセージが受信されたことを確認 - await page2.waitForSelector('#received-messages li', { state: 'attached' }) - const receivedMessage1 = await page2.$eval('#received-messages li', (el) => el.textContent) - - // 受信したメッセージが期待したものであるか検証 - // receivedMessage の先頭 26 バイトには sender_connection_id が含まれている - test.expect(receivedMessage1?.slice(0, 26)).toBe(page1ConnectionId) - // 27 文字目からは page1 のメッセージがそのまま - test.expect(receivedMessage1).toContain(page1Message) - - // page2からpage1へメッセージを送信 - const page2Message = 'Hello from page2' - await page2.fill('input[name="message"]', page2Message) - await page2.click('#send-message') - - // page1でメッセージが受信されたことを確認 - await page1.waitForSelector('#received-messages li', { state: 'attached' }) - const receivedMessage2 = await page1.$eval('#received-messages li', (el) => el.textContent) - - // 受信したメッセージが期待したものであるか検証 - console.log(`Received message on page1: ${receivedMessage2}`) - // receivedMessage の先頭 26 バイトには sender_connection_id が含まれている - test.expect(receivedMessage2?.slice(0, 26)).toBe(page2ConnectionId) - // 27 文字目からは page2 のメッセージがそのまま - test.expect(receivedMessage2).toContain(page2Message) - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await page1.click('#get-stats') - await page2.click('#get-stats') - - // 統計情報が表示されるまで待機 - await page1.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const page1StatsReportJson: Record[] = await page1.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // page1 stats report - const page1DataChannelStats = page1StatsReportJson.filter( - (report) => report.type === 'data-channel', - ) - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'signaling' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'push' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'notify' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'stats' && stats.state === 'open' - }), - ).toBeDefined() - - const page1ExampleStats = page1DataChannelStats.find((stats) => { - return stats.label === '#example' && stats.state === 'open' - }) - // ここで undefined ではないことを確認してる - expect(page1ExampleStats).toBeDefined() - expect(page1ExampleStats?.messagesSent).toBeGreaterThan(0) - expect(page1ExampleStats?.bytesSent).toBeGreaterThan(0) - expect(page1ExampleStats?.messagesSent).toBeGreaterThan(0) - - // 統計情報が表示されるまで待機 - await page2.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const page2StatsReportJson: Record[] = await page2.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // page2 stats report - const page2DataChannelStats = page2StatsReportJson.filter( - (report) => report.type === 'data-channel', - ) - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'signaling' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'push' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'notify' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'stats' && stats.state === 'open' - }), - ).toBeDefined() - - const page2ExampleStats = page2DataChannelStats.find((stats) => { - return stats.label === '#example' && stats.state === 'open' - }) - // ここで undefined ではないことを確認してる - expect(page2ExampleStats).toBeDefined() - expect(page2ExampleStats?.bytesReceived).toBeGreaterThan(0) - expect(page2ExampleStats?.messagesReceived).toBeGreaterThan(0) - expect(page2ExampleStats?.bytesSent).toBeGreaterThan(0) - expect(page2ExampleStats?.messagesSent).toBeGreaterThan(0) - - await page1.click('#disconnect') - await page2.click('#disconnect') - - await page1.close() - await page2.close() -}) diff --git a/examples/tests/messaging.spec.ts b/examples/tests/messaging.spec.ts deleted file mode 100644 index 7f47fa03..00000000 --- a/examples/tests/messaging.spec.ts +++ /dev/null @@ -1,197 +0,0 @@ -import { expect, test } from '@playwright/test' -import { isVersionGreaterThanOrEqual } from './helper' - -// sora-js-sdk のバージョンが 2024.2.0 以降の場合のみ実行したい -test('messaging pages', async ({ browser }) => { - // 新しいページを2つ作成 - const page1 = await browser.newPage() - const page2 = await browser.newPage() - - // それぞれのページに対して操作を行う - await page1.goto('http://localhost:9000/messaging/') - await page2.goto('http://localhost:9000/messaging/') - - // sora js sdk のバージョンを取得する - await page1.waitForSelector('#sora-js-sdk-version') - const page1SoraJsSdkVersion = await page1.$eval('#sora-js-sdk-version', (el) => el.textContent) - if (page1SoraJsSdkVersion === null) { - throw new Error('page1SoraJsSdkVersion is null') - } - // sora-js-sdk のバージョンが 2024.2.0 以上であるか確認して、2024.2.0 未満の場合はテストをスキップする - test.skip( - !isVersionGreaterThanOrEqual(page1SoraJsSdkVersion, '2024.2.0'), - 'sora-js-sdk のバージョンが 2024.2.0 以上である必要があります', - ) - - // Compress のTrue/Falseをランダムで設定する - const selectedCompress1 = await page1.evaluate(() => { - const checkCompress = document.getElementById('check-compress') as HTMLInputElement - const getRandomBoolean = (): boolean => Math.random() >= 0.5 - const randomCompress: boolean = getRandomBoolean() - checkCompress.checked = randomCompress - return randomCompress - }) - const selectedCompress2 = await page2.evaluate(() => { - const checkCompress = document.getElementById('check-compress') as HTMLInputElement - const getRandomBoolean = (): boolean => Math.random() >= 0.5 - const randomCompress: boolean = getRandomBoolean() - checkCompress.checked = randomCompress - return randomCompress - }) - // 設定した Compress の True/False をログに流す - console.log(`page1 Compress = ${selectedCompress1}`) - console.log(`page2 Compress = ${selectedCompress2}`) - - // connect ボタンを押して接続開始 - await page1.click('#connect') - await page2.click('#connect') - - await page1.waitForSelector('#connection-id:not(:empty)') - const page1ConnectionId = await page1.$eval('#connection-id', (el) => el.textContent) - console.log(`page1 connectionId=${page1ConnectionId}`) - - await page2.waitForSelector('#connection-id:not(:empty)') - const page2ConnectionId = await page2.$eval('#connection-id', (el) => el.textContent) - console.log(`page2 connectionId=${page2ConnectionId}`) - - // page1 で #example の DataChannel が open したことを確認 - await page1.waitForSelector('#messaging li', { state: 'attached' }) - - // page2 で #example の DataChannel が open したことを確認 - await page2.waitForSelector('#messaging li', { state: 'attached' }) - - // page1からpage2へメッセージを送信 - const page1Message = 'Hello from page1' - await page1.fill('input[name="message"]', page1Message) - await page1.click('#send-message') - - // page2でメッセージが受信されたことを確認 - await page2.waitForSelector('#received-messages li', { state: 'attached' }) - const receivedMessage1 = await page2.$eval('#received-messages li', (el) => el.textContent) - - // 受信したメッセージが期待したものであるか検証 - console.log(`Received message on page2: ${receivedMessage1}`) - test.expect(receivedMessage1).toBe(page1Message) - - // page2からpage1へメッセージを送信 - const page2Message = 'Hello from page2' - await page2.fill('input[name="message"]', page2Message) - await page2.click('#send-message') - - // page1でメッセージが受信されたことを確認 - await page1.waitForSelector('#received-messages li', { state: 'attached' }) - const receivedMessage2 = await page1.$eval('#received-messages li', (el) => el.textContent) - - // 受信したメッセージが期待したものであるか検証 - console.log(`Received message on page1: ${receivedMessage2}`) - test.expect(receivedMessage2).toBe(page2Message) - - // Compress で圧縮されているかを確認する(圧縮されていると Equal にならない) - if (selectedCompress1 !== selectedCompress2) { - test.expect(receivedMessage1).toEqual(page1Message) - test.expect(receivedMessage2).toEqual(page2Message) - } - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await page1.click('#get-stats') - await page2.click('#get-stats') - - // 統計情報が表示されるまで待機 - await page1.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const page1StatsReportJson: Record[] = await page1.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // page1 stats report - const page1DataChannelStats = page1StatsReportJson.filter( - (report) => report.type === 'data-channel', - ) - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'signaling' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'push' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'notify' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page1DataChannelStats.find((stats) => { - return stats.label === 'stats' && stats.state === 'open' - }), - ).toBeDefined() - - const page1ExampleStats = page1DataChannelStats.find((stats) => { - return stats.label === '#example' && stats.state === 'open' - }) - // ここで undefined ではないことを確認してる - expect(page1ExampleStats).toBeDefined() - expect(page1ExampleStats?.messagesSent).toBeGreaterThan(0) - expect(page1ExampleStats?.bytesSent).toBeGreaterThan(0) - expect(page1ExampleStats?.messagesSent).toBeGreaterThan(0) - - // 統計情報が表示されるまで待機 - await page2.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const page2StatsReportJson: Record[] = await page2.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // page2 stats report - const page2DataChannelStats = page2StatsReportJson.filter( - (report) => report.type === 'data-channel', - ) - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'signaling' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'push' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'notify' && stats.state === 'open' - }), - ).toBeDefined() - - expect( - page2DataChannelStats.find((stats) => { - return stats.label === 'stats' && stats.state === 'open' - }), - ).toBeDefined() - - const page2ExampleStats = page2DataChannelStats.find((stats) => { - return stats.label === '#example' && stats.state === 'open' - }) - // ここで undefined ではないことを確認してる - expect(page2ExampleStats).toBeDefined() - expect(page2ExampleStats?.bytesReceived).toBeGreaterThan(0) - expect(page2ExampleStats?.messagesReceived).toBeGreaterThan(0) - expect(page2ExampleStats?.bytesSent).toBeGreaterThan(0) - expect(page2ExampleStats?.messagesSent).toBeGreaterThan(0) - - await page1.click('#disconnect') - await page2.click('#disconnect') - - await page1.close() - await page2.close() -}) diff --git a/examples/tests/sendonly_audio.spec.ts b/examples/tests/sendonly_audio.spec.ts deleted file mode 100644 index a89b79c4..00000000 --- a/examples/tests/sendonly_audio.spec.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('sendonly audio pages', async ({ browser }) => { - // 新しいページを作成 - const sendonly = await browser.newPage() - // ページに対して操作を行う - await sendonly.goto('http://localhost:9000/sendonly_audio/') - - // select 要素から直接オプションを取得してランダムに選択する - // 音声コーデック - const selectedAudioCodec = await sendonly.evaluate(() => { - const select = document.querySelector('#audio-codec-type') as HTMLSelectElement - const options = Array.from(select.options) - const randomOption = options[Math.floor(Math.random() * options.length)] - select.value = randomOption.value - return randomOption.value - }) - // 音声ビットレート - const selectedBitRate = await sendonly.evaluate(() => { - const select = document.querySelector('#audio-bit-rate') as HTMLSelectElement - const options = Array.from(select.options).filter((option) => option.value !== '') // 未指定を除外 - const randomOption = options[Math.floor(Math.random() * options.length)] - select.value = randomOption.value - return randomOption.value - }) - - // ランダムで選択した音声コーデック・音声ビットレートをログに表示する - console.log(`Selected AudioCodec: ${selectedAudioCodec}`) - console.log(`Selected BitRate: ${selectedBitRate} kbps`) - - // 'connect' ボタンをクリックして音声の送信を開始する - await sendonly.click('#connect') - // #connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await sendonly.waitForSelector('#connection-id:not(:empty)') - // #connection-id 要素の内容を取得 - const sendonlyConnectionId = await sendonly.$eval('#connection-id', (el) => el.textContent) - console.log(`sendonly connectionId=${sendonlyConnectionId}`) - - // レース対策 - await sendonly.waitForTimeout(3000) - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await sendonly.click('#get-stats') - // 統計情報が表示されるまで待機 - await sendonly.waitForSelector('#stats-report') - - // データセットから統計情報を取得 - const sendonlyStatsReportJson: Record[] = await sendonly.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // 音声コーデックを確認する : 今は指定してもしなくても OPUS のみ - const sendonlyAudioCodecStats = sendonlyStatsReportJson.find( - (report) => report.type === 'codec' && report.mimeType === 'audio/opus', - ) - expect(sendonlyAudioCodecStats).toBeDefined() - - // 音声ビットレートを確認する:音声を送れているかと targetBitrate の確認 - const sendonlyAudioOutboundRtp = sendonlyStatsReportJson.find( - (report) => report.type === 'outbound-rtp' && report.kind === 'audio', - ) - expect(sendonlyAudioOutboundRtp).toBeDefined() - - // 音声が正常に送れているかを確認する - expect(sendonlyAudioOutboundRtp?.bytesSent).toBeGreaterThan(0) - expect(sendonlyAudioOutboundRtp?.packetsSent).toBeGreaterThan(0) - - // 音声ビットレートの選択に基づいて期待値を設定し一致するかを確認する - const expectedBitRate = Number.parseInt(selectedBitRate) * 1000 - expect(sendonlyAudioOutboundRtp?.targetBitrate).toEqual(expectedBitRate) - - await sendonly.click('#disconnect') - await sendonly.close() -}) diff --git a/examples/tests/sendonly_recvonly.spec.ts b/examples/tests/sendonly_recvonly.spec.ts deleted file mode 100644 index c296db2a..00000000 --- a/examples/tests/sendonly_recvonly.spec.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('sendonly/recvonly pages', async ({ browser }) => { - // 新しいページを2つ作成 - const sendonly = await browser.newPage() - const recvonly = await browser.newPage() - - // それぞれのページに対して操作を行う - await sendonly.goto('http://localhost:9000/sendonly/') - await recvonly.goto('http://localhost:9000/recvonly/') - - // SDK バージョンの表示 - await sendonly.waitForSelector('#sdk-version') - const sendonlySdkVersion = await sendonly.$eval('#sdk-version', (el) => el.textContent) - console.log(`sendonly sdkVersion=${sendonlySdkVersion}`) - - await recvonly.waitForSelector('#sdk-version') - const recvonlySdkVersion = await recvonly.$eval('#sdk-version', (el) => el.textContent) - console.log(`recvonly sdkVersion=${recvonlySdkVersion}`) - - await sendonly.click('#connect') - await recvonly.click('#connect') - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await sendonly.waitForSelector('#connection-id:not(:empty)') - - // #sendonly-connection-id 要素の内容を取得 - const sendonlyConnectionId = await sendonly.$eval('#connection-id', (el) => el.textContent) - console.log(`sendonly connectionId=${sendonlyConnectionId}`) - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await recvonly.waitForSelector('#connection-id:not(:empty)') - - // #sendrecv1-connection-id 要素の内容を取得 - const recvonlyConnectionId = await recvonly.$eval('#connection-id', (el) => el.textContent) - console.log(`recvonly connectionId=${recvonlyConnectionId}`) - - // レース対策 - await sendonly.waitForTimeout(3000) - await recvonly.waitForTimeout(3000) - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await sendonly.click('#get-stats') - - // 統計情報が表示されるまで待機 - await sendonly.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const sendonlyStatsReportJson: Record[] = await sendonly.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await recvonly.click('#get-stats') - - // 統計情報が表示されるまで待機 - await recvonly.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const recvonlyStatsReportJson: Record[] = await recvonly.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // sendonly audio codec - const sendonlyAudioCodecStats = sendonlyStatsReportJson.find( - (report) => report.type === 'codec' && report.mimeType === 'audio/opus', - ) - expect(sendonlyAudioCodecStats).toBeDefined() - - // sendonly audio outbound-rtp - const sendonlyAudioOutboundRtp = sendonlyStatsReportJson.find( - (report) => report.type === 'outbound-rtp' && report.kind === 'audio', - ) - expect(sendonlyAudioOutboundRtp).toBeDefined() - expect(sendonlyAudioOutboundRtp?.bytesSent).toBeGreaterThan(0) - expect(sendonlyAudioOutboundRtp?.packetsSent).toBeGreaterThan(0) - - // sendonly video codec - const sendonlyVideoCodecStats = sendonlyStatsReportJson.find( - (stats) => stats.type === 'codec' && stats.mimeType === 'video/VP9', - ) - expect(sendonlyVideoCodecStats).toBeDefined() - - // sendonly video outbound-rtp - const sendonlyVideoOutboundRtpStats = sendonlyStatsReportJson.find( - (stats) => stats.type === 'outbound-rtp' && stats.kind === 'video', - ) - expect(sendonlyVideoOutboundRtpStats).toBeDefined() - expect(sendonlyVideoOutboundRtpStats?.bytesSent).toBeGreaterThan(0) - expect(sendonlyVideoOutboundRtpStats?.packetsSent).toBeGreaterThan(0) - - // recvonly audio codec - const recvonlyAudioCodecStats = recvonlyStatsReportJson.find( - (stats) => stats.type === 'codec' && stats.mimeType === 'audio/opus', - ) - expect(recvonlyAudioCodecStats).toBeDefined() - - // recvonly audio inbound-rtp - const recvonlyAudioInboundRtpStats = recvonlyStatsReportJson.find( - (stats) => stats.type === 'inbound-rtp' && stats.kind === 'audio', - ) - expect(recvonlyAudioInboundRtpStats).toBeDefined() - expect(recvonlyAudioInboundRtpStats?.bytesReceived).toBeGreaterThan(0) - expect(recvonlyAudioInboundRtpStats?.packetsReceived).toBeGreaterThan(0) - - // recvonly video codec - const recvonlyVideoCodecStats = recvonlyStatsReportJson.find( - (stats) => stats.type === 'codec' && stats.mimeType === 'video/VP9', - ) - expect(recvonlyVideoCodecStats).toBeDefined() - - // recvonly video inbound-rtp - const recvonlyVideoInboundRtpStats = recvonlyStatsReportJson.find( - (stats) => stats.type === 'inbound-rtp' && stats.kind === 'video', - ) - expect(recvonlyVideoInboundRtpStats).toBeDefined() - expect(recvonlyVideoInboundRtpStats?.bytesReceived).toBeGreaterThan(0) - expect(recvonlyVideoInboundRtpStats?.packetsReceived).toBeGreaterThan(0) - - await sendonly.click('#disconnect') - await recvonly.click('#disconnect') - - await sendonly.close() - await recvonly.close() -}) diff --git a/examples/tests/sendrecv.spec.ts b/examples/tests/sendrecv.spec.ts deleted file mode 100644 index f04f6909..00000000 --- a/examples/tests/sendrecv.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('sendrecv x2', async ({ browser }) => { - const sendrecv1 = await browser.newPage() - const sendrecv2 = await browser.newPage() - - await sendrecv1.goto('http://localhost:9000/sendrecv/') - await sendrecv2.goto('http://localhost:9000/sendrecv/') - - // チャンネル名を設定 - await sendrecv1.fill('#channel-name', 'sendrecv-different-video-codec-type') - await sendrecv2.fill('#channel-name', 'sendrecv-different-video-codec-type') - - console.log('sendrecv1 channelName: sendrecv-different-video-codec-type') - console.log('sendrecv2 channelName: sendrecv-different-video-codec-type') - - // sendrecv1 のビデオコーデックをランダムに選択 - await sendrecv1.evaluate(() => { - const videoCodecTypeSelect = document.getElementById('video-codec-type') as HTMLSelectElement - const options = Array.from(videoCodecTypeSelect.options).filter((option) => option.value !== '') - const randomIndex = Math.floor(Math.random() * options.length) - videoCodecTypeSelect.value = options[randomIndex].value - }) - - // sendrecv2 のビデオコーデックをランダムに選択 - await sendrecv2.evaluate(() => { - const videoCodecTypeSelect = document.getElementById('video-codec-type') as HTMLSelectElement - const options = Array.from(videoCodecTypeSelect.options).filter((option) => option.value !== '') - const randomIndex = Math.floor(Math.random() * options.length) - videoCodecTypeSelect.value = options[randomIndex].value - }) - - // 選択されたコーデックをログに出力 - const sendrecv1VideoCodecType = await sendrecv1.$eval( - '#video-codec-type', - (el) => (el as HTMLSelectElement).value, - ) - const sendrecv2VideoCodecType = await sendrecv2.$eval( - '#video-codec-type', - (el) => (el as HTMLSelectElement).value, - ) - console.log(`sendrecv1 videoCodecType: ${sendrecv1VideoCodecType}`) - console.log(`sendrecv2 videoCodecType: ${sendrecv2VideoCodecType}`) - - await sendrecv1.click('#connect') - await sendrecv2.click('#connect') - - // #connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await sendrecv1.waitForSelector('#connection-id:not(:empty)') - - // #connection-id 要素の内容を取得 - const sendrecv1ConnectionId = await sendrecv1.$eval('#connection-id', (el) => el.textContent) - console.log(`sendrecv1 connectionId=${sendrecv1ConnectionId}`) - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await sendrecv2.waitForSelector('#connection-id:not(:empty)') - - // #sendrecv1-connection-id 要素の内容を取得 - const sendrecv2ConnectionId = await sendrecv2.$eval('#connection-id', (el) => el.textContent) - console.log(`sendrecv2 connectionId=${sendrecv2ConnectionId}`) - - // レース対策 - await sendrecv1.waitForTimeout(3000) - await sendrecv2.waitForTimeout(3000) - - // page1 stats report - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await sendrecv1.click('#get-stats') - - // 統計情報が表示されるまで待機 - await sendrecv1.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const sendrecv1StatsReportJson: Record[] = await sendrecv1.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - const sendrecv1VideoCodecStats = sendrecv1StatsReportJson.find( - (stats) => stats.type === 'codec' && stats.mimeType === `video/${sendrecv1VideoCodecType}`, - ) - expect(sendrecv1VideoCodecStats).toBeDefined() - - const sendrecv1VideoOutboundRtpStats = sendrecv1StatsReportJson.find( - (stats) => stats.type === 'outbound-rtp' && stats.kind === 'video', - ) - expect(sendrecv1VideoOutboundRtpStats).toBeDefined() - expect(sendrecv1VideoOutboundRtpStats?.bytesSent).toBeGreaterThan(0) - expect(sendrecv1VideoOutboundRtpStats?.packetsSent).toBeGreaterThan(0) - - const sendrecv1VideoInboundRtpStats = sendrecv1StatsReportJson.find( - (stats) => stats.type === 'inbound-rtp' && stats.kind === 'video', - ) - expect(sendrecv1VideoInboundRtpStats).toBeDefined() - expect(sendrecv1VideoInboundRtpStats?.bytesReceived).toBeGreaterThan(0) - expect(sendrecv1VideoInboundRtpStats?.packetsReceived).toBeGreaterThan(0) - - // page2 stats report - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await sendrecv2.click('#get-stats') - - // 統計情報が表示されるまで待機 - await sendrecv2.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const sendrecv2StatsReportJson: Record[] = await sendrecv2.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - const sendrecv2VideoCodecStats = sendrecv2StatsReportJson.find( - (stats) => stats.type === 'codec' && stats.mimeType === `video/${sendrecv2VideoCodecType}`, - ) - expect(sendrecv2VideoCodecStats).toBeDefined() - - const sendrecv2VideoOutboundRtpStats = sendrecv2StatsReportJson.find( - (stats) => stats.type === 'outbound-rtp' && stats.kind === 'video', - ) - expect(sendrecv2VideoOutboundRtpStats).toBeDefined() - expect(sendrecv2VideoOutboundRtpStats?.bytesSent).toBeGreaterThan(0) - expect(sendrecv2VideoOutboundRtpStats?.packetsSent).toBeGreaterThan(0) - - const sendrecv2VideoInboundRtpStats = sendrecv2StatsReportJson.find( - (stats) => stats.type === 'inbound-rtp' && stats.kind === 'video', - ) - expect(sendrecv2VideoInboundRtpStats).toBeDefined() - expect(sendrecv2VideoInboundRtpStats?.bytesReceived).toBeGreaterThan(0) - expect(sendrecv2VideoInboundRtpStats?.packetsReceived).toBeGreaterThan(0) - - await sendrecv1.click('#disconnect') - await sendrecv2.click('#disconnect') - - await sendrecv1.close() - await sendrecv2.close() -}) diff --git a/examples/tests/simulcast.spec.ts b/examples/tests/simulcast.spec.ts deleted file mode 100644 index d1488b4f..00000000 --- a/examples/tests/simulcast.spec.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('simulcast sendonly/recvonly pages', async ({ page }) => { - await page.goto('http://localhost:9000/simulcast/') - - await page.click('#connect') - - // 安全によせて 5 秒待つ - await page.waitForTimeout(5000) - - await page.waitForSelector('#local-video-connection-id:not(:empty)') - const localConnectionId = await page.$eval('#local-video-connection-id', (el) => el.textContent) - console.log(`local connectionId=${localConnectionId}`) - - await page.waitForSelector('#remote-video-connection-id-r0:not(:empty)') - const remoteR0ConnectionId = await page.$eval( - '#remote-video-connection-id-r0', - (el) => el.textContent, - ) - console.log(`remote | rid=r0, connectionId=${remoteR0ConnectionId}`) - - await page.waitForSelector('#remote-video-connection-id-r1:not(:empty)') - const remoteR1ConnectionId = await page.$eval( - '#remote-video-connection-id-r1', - (el) => el.textContent, - ) - console.log(`remote | rid=r1, connectionId=${remoteR1ConnectionId}`) - - await page.waitForSelector('#remote-video-connection-id-r2:not(:empty)') - const remoteR2ConnectionId = await page.$eval( - '#remote-video-connection-id-r2', - (el) => el.textContent, - ) - console.log(`remote | rid=r2, connectionId=${remoteR2ConnectionId}`) - - // 'Get Stats' ボタンをクリックして統計情報を取得 - await page.click('#get-stats') - - // 統計情報が表示されるまで待機 - await page.waitForSelector('#stats-report') - // データセットから統計情報を取得 - const sendonlyStatsReportJson: Record[] = await page.evaluate(() => { - const statsReportDiv = document.querySelector('#stats-report') as HTMLDivElement - return statsReportDiv ? JSON.parse(statsReportDiv.dataset.statsReportJson || '[]') : [] - }) - - // sendonly stats report - const sendonlyVideoCodecStats = sendonlyStatsReportJson.find( - (stats) => stats.type === 'codec' && stats.mimeType === 'video/VP8', - ) - expect(sendonlyVideoCodecStats).toBeDefined() - - const sendonlyVideoR0OutboundRtpStats = sendonlyStatsReportJson.find( - (stats) => stats.type === 'outbound-rtp' && stats.kind === 'video' && stats.rid === 'r0', - ) - expect(sendonlyVideoR0OutboundRtpStats).toBeDefined() - expect(sendonlyVideoR0OutboundRtpStats?.bytesSent).toBeGreaterThan(0) - expect(sendonlyVideoR0OutboundRtpStats?.packetsSent).toBeGreaterThan(0) - expect(sendonlyVideoR0OutboundRtpStats?.scalabilityMode).toEqual('L1T1') - - const sendonlyVideoR1OutboundRtpStats = sendonlyStatsReportJson.find( - (stats) => stats.type === 'outbound-rtp' && stats.kind === 'video' && stats.rid === 'r1', - ) - expect(sendonlyVideoR1OutboundRtpStats).toBeDefined() - expect(sendonlyVideoR1OutboundRtpStats?.bytesSent).toBeGreaterThan(0) - expect(sendonlyVideoR1OutboundRtpStats?.packetsSent).toBeGreaterThan(0) - expect(sendonlyVideoR1OutboundRtpStats?.scalabilityMode).toEqual('L1T1') - - const sendonlyVideoR2OutboundRtpStats = sendonlyStatsReportJson.find( - (stats) => stats.type === 'outbound-rtp' && stats.kind === 'video' && stats.rid === 'r2', - ) - expect(sendonlyVideoR2OutboundRtpStats).toBeDefined() - expect(sendonlyVideoR2OutboundRtpStats?.bytesSent).toBeGreaterThan(0) - expect(sendonlyVideoR2OutboundRtpStats?.packetsSent).toBeGreaterThan(0) - expect(sendonlyVideoR2OutboundRtpStats?.scalabilityMode).toEqual('L1T1') - - await page.click('#disconnect') -}) diff --git a/examples/tests/spotlight_sendonly_recvonly.spec.ts b/examples/tests/spotlight_sendonly_recvonly.spec.ts deleted file mode 100644 index 89c09921..00000000 --- a/examples/tests/spotlight_sendonly_recvonly.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test } from '@playwright/test' - -test('spotlight sendonly/recvonly pages', async ({ browser }) => { - // 新しいページを2つ作成 - const sendonly = await browser.newPage() - const recvonly = await browser.newPage() - - // それぞれのページに対して操作を行う - await sendonly.goto('http://localhost:9000/spotlight_sendonly/') - await recvonly.goto('http://localhost:9000/spotlight_recvonly/') - - await sendonly.click('#connect') - await recvonly.click('#connect') - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await sendonly.waitForSelector('#connection-id:not(:empty)') - - // #sendonly-connection-id 要素の内容を取得 - const sendonlyConnectionId = await sendonly.$eval('#connection-id', (el) => el.textContent) - console.log(`sendonly connectionId=${sendonlyConnectionId}`) - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await recvonly.waitForSelector('#connection-id:not(:empty)') - - // #sendrecv1-connection-id 要素の内容を取得 - const recvonlyConnectionId = await recvonly.$eval('#connection-id', (el) => el.textContent) - console.log(`recvonly connectionId=${recvonlyConnectionId}`) - - await sendonly.click('#disconnect') - await recvonly.click('#disconnect') - - await sendonly.close() - await recvonly.close() -}) diff --git a/examples/tests/spotlight_sendrecv.spec.ts b/examples/tests/spotlight_sendrecv.spec.ts deleted file mode 100644 index 550d2d41..00000000 --- a/examples/tests/spotlight_sendrecv.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { test } from '@playwright/test' - -test('spotlight sendrecv x2', async ({ page }) => { - await page.goto('http://localhost:9000/spotlight_sendrecv/') - - await page.click('#sendrecv1-connect') - await page.click('#sendrecv2-connect') - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await page.waitForSelector('#sendrecv1-connection-id:not(:empty)') - - // #sendrecv1-connection-id 要素の内容を取得 - const sendrecv1ConnectionId = await page.$eval('#sendrecv1-connection-id', (el) => el.textContent) - console.log(`sendrecv1 connectionId=${sendrecv1ConnectionId}`) - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await page.waitForSelector('#sendrecv1-connection-id:not(:empty)') - - // #sendrecv1-connection-id 要素の内容を取得 - const sendrecv2ConnectionId = await page.$eval('#sendrecv2-connection-id', (el) => el.textContent) - console.log(`sendrecv2 connectionId=${sendrecv2ConnectionId}`) - - await page.click('#sendrecv1-disconnect') - await page.click('#sendrecv2-disconnect') -}) diff --git a/examples/tests/type_close.spec.ts b/examples/tests/type_close.spec.ts deleted file mode 100644 index 3d3b5ce4..00000000 --- a/examples/tests/type_close.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('data_channel_signaling_only type:close pages', async ({ browser }) => { - // 新しいページを2つ作成 - const dataChannelSignalingOnly = await browser.newPage() - - // デバッグ用 - dataChannelSignalingOnly.on('console', (msg) => { - console.log(msg.type(), msg.text()) - }) - - // それぞれのページに対して操作を行う - await dataChannelSignalingOnly.goto('http://localhost:9000/data_channel_signaling_only/') - - // SDK バージョンの表示 - await dataChannelSignalingOnly.waitForSelector('#sdk-version') - const dataChannelSignalingOnlySdkVersion = await dataChannelSignalingOnly.$eval( - '#sdk-version', - (el) => el.textContent, - ) - console.log(`dataChannelSignalingOnly sdkVersion=${dataChannelSignalingOnlySdkVersion}`) - - await dataChannelSignalingOnly.click('#connect') - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await dataChannelSignalingOnly.waitForSelector('#connection-id:not(:empty)') - - // #sendonly-connection-id 要素の内容を取得 - const dataChannelSignalingOnlyConnectionId = await dataChannelSignalingOnly.$eval( - '#connection-id', - (el) => el.textContent, - ) - console.log(`dataChannelSignalingOnly connectionId=${dataChannelSignalingOnlyConnectionId}`) - - // レース対策 - await dataChannelSignalingOnly.waitForTimeout(3000) - - // API で切断 - await dataChannelSignalingOnly.click('#disconnect-api') - // console.log に [signaling] switched が出力されるまで待機するための Promise を作成する - const consolePromise = dataChannelSignalingOnly.waitForEvent('console') - - // レース対策 - await dataChannelSignalingOnly.waitForTimeout(3000) - - // Console log の Promise が解決されるまで待機する - const msg = await consolePromise - // log [signaling] onmessage-close websocket が出力されるので、args 0/1/2 をそれぞれチェックする - // [signaling] - const value1 = await msg.args()[0].jsonValue() - expect(value1).toBe('[signaling]') - // onmessage-close - const value2 = await msg.args()[1].jsonValue() - expect(value2).toBe('onmessage-close') - // websocket - const value3 = await msg.args()[2].jsonValue() - expect(value3).toBe('datachannel') - - await dataChannelSignalingOnly.close() -}) diff --git a/examples/tests/type_switched.spec.ts b/examples/tests/type_switched.spec.ts deleted file mode 100644 index f1a6b699..00000000 --- a/examples/tests/type_switched.spec.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('data_channel_signaling_only type:switched pages', async ({ browser }) => { - // 新しいページを2つ作成 - const dataChannelSignalingOnly = await browser.newPage() - - // デバッグ用 - // dataChannelSignalingOnly.on('console', (msg) => { - // console.log(msg.type(), msg.text()) - // }) - - // それぞれのページに対して操作を行う - await dataChannelSignalingOnly.goto('http://localhost:9000/data_channel_signaling_only/') - - // SDK バージョンの表示 - await dataChannelSignalingOnly.waitForSelector('#sdk-version') - const dataChannelSignalingOnlySdkVersion = await dataChannelSignalingOnly.$eval( - '#sdk-version', - (el) => el.textContent, - ) - console.log(`dataChannelSignalingOnly sdkVersion=${dataChannelSignalingOnlySdkVersion}`) - - await dataChannelSignalingOnly.click('#connect') - // console.log に [signaling] switched が出力されるまで待機するための Promise を作成する - const consolePromise = dataChannelSignalingOnly.waitForEvent('console') - - // #sendrecv1-connection-id 要素が存在し、その内容が空でないことを確認するまで待つ - await dataChannelSignalingOnly.waitForSelector('#connection-id:not(:empty)') - - // #sendonly-connection-id 要素の内容を取得 - const dataChannelSignalingOnlyConnectionId = await dataChannelSignalingOnly.$eval( - '#connection-id', - (el) => el.textContent, - ) - console.log(`dataChannelSignalingOnly connectionId=${dataChannelSignalingOnlyConnectionId}`) - - // レース対策 - await dataChannelSignalingOnly.waitForTimeout(3000) - - // Console log の Promise が解決されるまで待機する - const msg = await consolePromise - // log [signaling] onmessage-switched websocket が出力されるので、args 0/1/2 をそれぞれチェックする - // [signaling] - const value1 = await msg.args()[0].jsonValue() - expect(value1).toBe('[signaling]') - // onmessage-switched - const value2 = await msg.args()[1].jsonValue() - expect(value2).toBe('onmessage-switched') - // websocket - const value3 = await msg.args()[2].jsonValue() - expect(value3).toBe('websocket') - - await dataChannelSignalingOnly.click('#disconnect') - - await dataChannelSignalingOnly.close() -}) diff --git a/examples/tests/whip_whep.spec.ts b/examples/tests/whip_whep.spec.ts deleted file mode 100644 index d211de97..00000000 --- a/examples/tests/whip_whep.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { expect, test } from '@playwright/test' - -test('whip/whep', async ({ browser }) => { - const whip = await browser.newPage() - const whep = await browser.newPage() - - await whip.goto('http://localhost:9000/whip/') - await whep.goto('http://localhost:9000/whep/') - - // コーデックの取得 - const whipVideoCodecType = await whip.evaluate(() => { - const videoElement = document.querySelector('#video-codec-type') as HTMLSelectElement - return videoElement.value - }) - console.log(`whipVideoCodecType=${whipVideoCodecType}`) - - const whepVideoCodecType = await whep.evaluate(() => { - const videoElement = document.querySelector('#video-codec-type') as HTMLSelectElement - return videoElement.value - }) - console.log(`whepVideoCodecType=${whepVideoCodecType}`) - - await whip.click('#connect') - await whep.click('#connect') - - // connection-stateが"connected"になるまで待つ - await whip.waitForSelector('#connection-state:has-text("connected")') - await whep.waitForSelector('#connection-state:has-text("connected")') - - // connection-stateの値を取得して確認 - const whipConnectionState = await whip.$eval('#connection-state', (el) => el.textContent) - console.log(`whip connectionState=${whipConnectionState}`) - - const whepConnectionState = await whep.$eval('#connection-state', (el) => el.textContent) - console.log(`whep connectionState=${whepConnectionState}`) - - await whip.click('#disconnect') - await whep.click('#disconnect') - - await whip.close() - await whep.close() -})