• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Copyright (c) 2024 Huawei Device Co., Ltd.
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9    http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16
17Description: Fixtures of pytest.
18"""
19
20import logging
21import os
22
23import pytest
24
25from aw import Application
26from aw import Fport
27from aw import TaskPool
28from aw import WebSocket
29
30
31@pytest.fixture(scope='class')
32def test_suite_debug_01():
33    logging.info('running test_suite_debug_01')
34
35    bundle_name = 'com.example.worker'
36    hap_name = 'MyApplicationWorker.hap'
37
38    config = {'connect_server_port': 15678,
39              'debugger_server_port': 15679,
40              'bundle_name': bundle_name,
41              'hap_path': rf'{os.path.dirname(__file__)}\..\resource\{hap_name}'}
42
43    pid = Application.launch_application(config['bundle_name'], config['hap_path'], start_mode='-D')
44    assert pid != 0, logging.error(f'Pid of {hap_name} is 0!')
45    config['pid'] = pid
46
47    Fport.clear_fport()
48    Fport.fport_connect_server(config['connect_server_port'], config['pid'], config['bundle_name'])
49
50    config['websocket'] = WebSocket(config['connect_server_port'], config['debugger_server_port'])
51
52    config['taskpool'] = TaskPool()
53
54    return config
55