import { describe, it, expect } from "@normalized:N&&&@ohos/hypium/index&1.0.25";
import { PageStartedEvent, PageFinishedEvent, PermissionGrantedEvent, PermissionDeniedEvent, SchemeInterceptedEvent, SchemeNotMatchedEvent, LoadErrorEvent, HttpErrorEvent, SslErrorEvent, DownloadStartEvent, DownloadFailedEvent, RenderProcessGoneEvent, UserAgentInjectFailedEvent } from "@normalized:N&&&tencentqianwebview/src/main/ets/model/SdkEvent&1.0.0";
/**
 * SdkEvent 各类型构造与字段验证。
 *
 * 对应 spec.md SdkEvent Data Model 的所有 Scenarios。
 */
export default function sdkEventTest() {
    describe('SdkEvent', () => {
        it('PageStartedEvent_carriesUrl', 0, () => {
            const e = new PageStartedEvent('https://x');
            expect(e.type).assertEqual('PageStarted');
            expect(e.url).assertEqual('https://x');
        });
        it('PageFinishedEvent_carriesUrl', 0, () => {
            const e = new PageFinishedEvent('https://x');
            expect(e.type).assertEqual('PageFinished');
            expect(e.url).assertEqual('https://x');
        });
        it('PermissionGrantedEvent_carriesPermissionList', 0, () => {
            const e = new PermissionGrantedEvent(['ohos.permission.CAMERA']);
            expect(e.type).assertEqual('PermissionGranted');
            expect(e.permissions.length).assertEqual(1);
            expect(e.permissions[0]).assertEqual('ohos.permission.CAMERA');
        });
        it('PermissionDeniedEvent_carriesPermissionList', 0, () => {
            const e = new PermissionDeniedEvent(['ohos.permission.MICROPHONE']);
            expect(e.type).assertEqual('PermissionDenied');
            expect(e.permissions[0]).assertEqual('ohos.permission.MICROPHONE');
        });
        it('SchemeInterceptedEvent_carriesSchemeAndUrl', 0, () => {
            const e = new SchemeInterceptedEvent('qianapp', 'qianapp://x?action=sign');
            expect(e.type).assertEqual('SchemeIntercepted');
            expect(e.scheme).assertEqual('qianapp');
            expect(e.url).assertEqual('qianapp://x?action=sign');
        });
        it('SchemeNotMatchedEvent_carriesUrl', 0, () => {
            const e = new SchemeNotMatchedEvent('unknownapp://x');
            expect(e.type).assertEqual('SchemeNotMatched');
            expect(e.url).assertEqual('unknownapp://x');
        });
        it('LoadErrorEvent_carriesErrorDetails', 0, () => {
            const e = new LoadErrorEvent('https://x', -2, 'NET_DISCONNECTED');
            expect(e.type).assertEqual('LoadError');
            expect(e.errorCode).assertEqual(-2);
            expect(e.description).assertEqual('NET_DISCONNECTED');
        });
        it('HttpErrorEvent_carriesStatusCode', 0, () => {
            const e = new HttpErrorEvent('https://x', 404, 'Not Found');
            expect(e.type).assertEqual('HttpError');
            expect(e.statusCode).assertEqual(404);
        });
        it('SslErrorEvent_carriesUrlAndPrimaryError', 0, () => {
            const e = new SslErrorEvent('https://x', 3);
            expect(e.type).assertEqual('SslError');
            expect(e.url).assertEqual('https://x');
            expect(e.primaryError).assertEqual(3);
        });
        it('DownloadStartEvent_carriesUrlAndMime', 0, () => {
            const e = new DownloadStartEvent('https://x/file.pdf', 'application/pdf', 'attachment');
            expect(e.type).assertEqual('DownloadStart');
            expect(e.url).assertEqual('https://x/file.pdf');
            expect(e.mimeType).assertEqual('application/pdf');
        });
        it('DownloadFailedEvent_carriesUrlAndReason', 0, () => {
            const e = new DownloadFailedEvent('https://x/file.pdf', 'no browser');
            expect(e.type).assertEqual('DownloadFailed');
            expect(e.reason).assertEqual('no browser');
        });
        it('RenderProcessGoneEvent_carriesCrashFlag', 0, () => {
            const e = new RenderProcessGoneEvent(true, 'https://x');
            expect(e.type).assertEqual('RenderProcessGone');
            expect(e.didCrash).assertTrue();
            expect(e.url).assertEqual('https://x');
        });
        it('UserAgentInjectFailedEvent_carriesReason', 0, () => {
            const e = new UserAgentInjectFailedEvent('controller not ready');
            expect(e.type).assertEqual('UserAgentInjectFailed');
            expect(e.reason).assertEqual('controller not ready');
        });
    });
}
