176e6818aSopenharmony_ci#!/usr/bin/env python3
276e6818aSopenharmony_ci# coding=utf-8
376e6818aSopenharmony_ci
476e6818aSopenharmony_ci#
576e6818aSopenharmony_ci# Copyright (c) 2022 Huawei Device Co., Ltd.
676e6818aSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
776e6818aSopenharmony_ci# you may not use this file except in compliance with the License.
876e6818aSopenharmony_ci# You may obtain a copy of the License at
976e6818aSopenharmony_ci#
1076e6818aSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
1176e6818aSopenharmony_ci#
1276e6818aSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1376e6818aSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1476e6818aSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1576e6818aSopenharmony_ci# See the License for the specific language governing permissions and
1676e6818aSopenharmony_ci# limitations under the License.
1776e6818aSopenharmony_ci#
1876e6818aSopenharmony_ci
1976e6818aSopenharmony_ciclass TestAssertionError(Exception):
2076e6818aSopenharmony_ci    """
2176e6818aSopenharmony_ci    devicetest defined assertion class
2276e6818aSopenharmony_ci    """
2376e6818aSopenharmony_ci
2476e6818aSopenharmony_ci    def __init__(self, error_msg):
2576e6818aSopenharmony_ci        super(TestAssertionError, self).__init__(error_msg)
2676e6818aSopenharmony_ci        self.error_msg = error_msg
2776e6818aSopenharmony_ci
2876e6818aSopenharmony_ci    def __str__(self):
2976e6818aSopenharmony_ci        return str(self.error_msg)
3076e6818aSopenharmony_ci
3176e6818aSopenharmony_ci
3276e6818aSopenharmony_ciclass RPCException(Exception):
3376e6818aSopenharmony_ci    def __init__(self, error_msg):
3476e6818aSopenharmony_ci        super(RPCException, self).__init__(error_msg)
3576e6818aSopenharmony_ci        self.error_msg = error_msg
3676e6818aSopenharmony_ci
3776e6818aSopenharmony_ci    def __str__(self):
3876e6818aSopenharmony_ci        return str(self.error_msg)
3976e6818aSopenharmony_ci
4076e6818aSopenharmony_ci
4176e6818aSopenharmony_ciclass RPCAPIError(RPCException):
4276e6818aSopenharmony_ci    """Raised when remote API reports an error."""
4376e6818aSopenharmony_ci
4476e6818aSopenharmony_ci    def __init__(self, error_msg):
4576e6818aSopenharmony_ci        super(RPCAPIError, self).__init__(error_msg)
4676e6818aSopenharmony_ci        self.error_msg = error_msg
4776e6818aSopenharmony_ci
4876e6818aSopenharmony_ci    def __str__(self):
4976e6818aSopenharmony_ci        return str(self.error_msg)
5076e6818aSopenharmony_ci
5176e6818aSopenharmony_ci
5276e6818aSopenharmony_ciclass DeccAgentError(Exception):
5376e6818aSopenharmony_ci    def __init__(self, error_msg):
5476e6818aSopenharmony_ci        super(DeccAgentError, self).__init__(error_msg)
5576e6818aSopenharmony_ci        self.error_msg = error_msg
5676e6818aSopenharmony_ci
5776e6818aSopenharmony_ci    def __str__(self):
5876e6818aSopenharmony_ci        return str(self.error_msg)
5976e6818aSopenharmony_ci
6076e6818aSopenharmony_ci
6176e6818aSopenharmony_ciclass DeviceTestError(Exception):
6276e6818aSopenharmony_ci    def __init__(self, error_msg):
6376e6818aSopenharmony_ci        super(DeviceTestError, self).__init__(error_msg)
6476e6818aSopenharmony_ci        self.error_msg = error_msg
6576e6818aSopenharmony_ci
6676e6818aSopenharmony_ci    def __str__(self):
6776e6818aSopenharmony_ci        return str(self.error_msg)
6876e6818aSopenharmony_ci
6976e6818aSopenharmony_ci
7076e6818aSopenharmony_ciclass BaseTestError(Exception):
7176e6818aSopenharmony_ci    """Raised for exceptions that occured in BaseTestClass.
7276e6818aSopenharmony_ci    """
7376e6818aSopenharmony_ci
7476e6818aSopenharmony_ci    def __init__(self, error_msg):
7576e6818aSopenharmony_ci        super(BaseTestError, self).__init__(error_msg)
7676e6818aSopenharmony_ci        self.error_msg = error_msg
7776e6818aSopenharmony_ci
7876e6818aSopenharmony_ci    def __str__(self):
7976e6818aSopenharmony_ci        return str(self.error_msg)
8076e6818aSopenharmony_ci
8176e6818aSopenharmony_ci
8276e6818aSopenharmony_ciclass TestFailure(Exception):
8376e6818aSopenharmony_ci    """Raised when a check has failed."""
8476e6818aSopenharmony_ci
8576e6818aSopenharmony_ci    def __init__(self, error_msg):
8676e6818aSopenharmony_ci        super(TestFailure, self).__init__(error_msg)
8776e6818aSopenharmony_ci        self.error_msg = error_msg
8876e6818aSopenharmony_ci
8976e6818aSopenharmony_ci    def __str__(self):
9076e6818aSopenharmony_ci        return str(self.error_msg)
9176e6818aSopenharmony_ci
9276e6818aSopenharmony_ci
9376e6818aSopenharmony_ciclass TestError(Exception):
9476e6818aSopenharmony_ci    """Raised when a step has failed."""
9576e6818aSopenharmony_ci
9676e6818aSopenharmony_ci    def __init__(self, error_msg):
9776e6818aSopenharmony_ci        super(TestError, self).__init__(error_msg)
9876e6818aSopenharmony_ci        self.error_msg = error_msg
9976e6818aSopenharmony_ci
10076e6818aSopenharmony_ci    def __str__(self):
10176e6818aSopenharmony_ci        return str(self.error_msg)
10276e6818aSopenharmony_ci
10376e6818aSopenharmony_ci
10476e6818aSopenharmony_ciclass TestSkip(Exception):
10576e6818aSopenharmony_ci    """Raised when a test has been skipped."""
10676e6818aSopenharmony_ci
10776e6818aSopenharmony_ci    def __init__(self, error_msg):
10876e6818aSopenharmony_ci        super(TestSkip, self).__init__(error_msg)
10976e6818aSopenharmony_ci        self.error_msg = error_msg
11076e6818aSopenharmony_ci
11176e6818aSopenharmony_ci    def __str__(self):
11276e6818aSopenharmony_ci        return str(self.error_msg)
11376e6818aSopenharmony_ci
11476e6818aSopenharmony_ci
11576e6818aSopenharmony_ciclass TestTerminated(Exception):
11676e6818aSopenharmony_ci    """Raised when a test has been stopped."""
11776e6818aSopenharmony_ci
11876e6818aSopenharmony_ci    def __init__(self, error_msg):
11976e6818aSopenharmony_ci        super(TestTerminated, self).__init__(error_msg)
12076e6818aSopenharmony_ci        self.error_msg = error_msg
12176e6818aSopenharmony_ci
12276e6818aSopenharmony_ci    def __str__(self):
12376e6818aSopenharmony_ci        return str(self.error_msg)
12476e6818aSopenharmony_ci
12576e6818aSopenharmony_ci
12676e6818aSopenharmony_ciclass TestAbortManual(Exception):
12776e6818aSopenharmony_ci    """Raised when a manual abort occurs."""
12876e6818aSopenharmony_ci
12976e6818aSopenharmony_ci    def __init__(self, error_msg):
13076e6818aSopenharmony_ci        super(TestAbortManual, self).__init__(error_msg)
13176e6818aSopenharmony_ci        self.error_msg = error_msg
13276e6818aSopenharmony_ci
13376e6818aSopenharmony_ci    def __str__(self):
13476e6818aSopenharmony_ci        return str(self.error_msg)
13576e6818aSopenharmony_ci
13676e6818aSopenharmony_ci
13776e6818aSopenharmony_ciclass TestPrepareError(Exception):
13876e6818aSopenharmony_ci    """raise exception when prepare error."""
13976e6818aSopenharmony_ci
14076e6818aSopenharmony_ci    def __init__(self, error_msg):
14176e6818aSopenharmony_ci        super(TestPrepareError, self).__init__(error_msg)
14276e6818aSopenharmony_ci        self.error_msg = error_msg
14376e6818aSopenharmony_ci
14476e6818aSopenharmony_ci    def __str__(self):
14576e6818aSopenharmony_ci        return str(self.error_msg)
14676e6818aSopenharmony_ci
14776e6818aSopenharmony_ci
14876e6818aSopenharmony_ciclass DeviceNotFound(Exception):
14976e6818aSopenharmony_ci    """raise exception when device not found."""
15076e6818aSopenharmony_ci
15176e6818aSopenharmony_ci    def __init__(self, error_msg):
15276e6818aSopenharmony_ci        super(DeviceNotFound, self).__init__(error_msg)
15376e6818aSopenharmony_ci        self.error_msg = error_msg
15476e6818aSopenharmony_ci
15576e6818aSopenharmony_ci    def __str__(self):
15676e6818aSopenharmony_ci        return str(self.error_msg)
15776e6818aSopenharmony_ci
15876e6818aSopenharmony_ci
15976e6818aSopenharmony_ciclass DeviceTestAppInstallError(Exception):
16076e6818aSopenharmony_ci    """
16176e6818aSopenharmony_ci    Failed to install the APP
16276e6818aSopenharmony_ci    """
16376e6818aSopenharmony_ci
16476e6818aSopenharmony_ci    def __init__(self, error_msg):
16576e6818aSopenharmony_ci        super(DeviceTestAppInstallError, self).__init__(error_msg)
16676e6818aSopenharmony_ci        self.error_msg = error_msg
16776e6818aSopenharmony_ci
16876e6818aSopenharmony_ci    def __str__(self):
16976e6818aSopenharmony_ci        return str(self.error_msg)
17076e6818aSopenharmony_ci
17176e6818aSopenharmony_ci
17276e6818aSopenharmony_ciclass DeviceTestRpcNotRunningError(Exception):
17376e6818aSopenharmony_ci    """
17476e6818aSopenharmony_ci    RPC not running
17576e6818aSopenharmony_ci    """
17676e6818aSopenharmony_ci
17776e6818aSopenharmony_ci    def __init__(self, error_msg):
17876e6818aSopenharmony_ci        super(DeviceTestRpcNotRunningError, self).__init__(error_msg)
17976e6818aSopenharmony_ci        self.error_msg = error_msg
18076e6818aSopenharmony_ci
18176e6818aSopenharmony_ci    def __str__(self):
18276e6818aSopenharmony_ci        return str(self.error_msg)
18376e6818aSopenharmony_ci
18476e6818aSopenharmony_ci
18576e6818aSopenharmony_ciclass DeviceTestHdcCommandRejectedException(Exception):
18676e6818aSopenharmony_ci    """
18776e6818aSopenharmony_ci    Failed to connect to the device:The device goes offline
18876e6818aSopenharmony_ci    """
18976e6818aSopenharmony_ci
19076e6818aSopenharmony_ci    def __init__(self, error_msg):
19176e6818aSopenharmony_ci        super(DeviceTestHdcCommandRejectedException, self).__init__(error_msg)
19276e6818aSopenharmony_ci        self.error_msg = error_msg
19376e6818aSopenharmony_ci
19476e6818aSopenharmony_ci    def __str__(self):
19576e6818aSopenharmony_ci        return str(self.error_msg)
19676e6818aSopenharmony_ci
19776e6818aSopenharmony_ci
19876e6818aSopenharmony_ciclass DeviceTestShellCommandUnresponsiveException(Exception):
19976e6818aSopenharmony_ci    """
20076e6818aSopenharmony_ci    Running the connector command times out
20176e6818aSopenharmony_ci    """
20276e6818aSopenharmony_ci
20376e6818aSopenharmony_ci    def __init__(self, error_msg):
20476e6818aSopenharmony_ci        super(DeviceTestShellCommandUnresponsiveException,
20576e6818aSopenharmony_ci              self).__init__(error_msg)
20676e6818aSopenharmony_ci        self.error_msg = error_msg
20776e6818aSopenharmony_ci
20876e6818aSopenharmony_ci    def __str__(self):
20976e6818aSopenharmony_ci        return str(self.error_msg)
21076e6818aSopenharmony_ci
21176e6818aSopenharmony_ci
21276e6818aSopenharmony_ciclass DoesNotExistError(Exception):
21376e6818aSopenharmony_ci    """
21476e6818aSopenharmony_ci    Viewnode is none
21576e6818aSopenharmony_ci    """
21676e6818aSopenharmony_ci
21776e6818aSopenharmony_ci    def __init__(self, error_msg):
21876e6818aSopenharmony_ci        super(DoesNotExistError, self).__init__(error_msg)
21976e6818aSopenharmony_ci        self.error_msg = error_msg
22076e6818aSopenharmony_ci
22176e6818aSopenharmony_ci    def __str__(self):
22276e6818aSopenharmony_ci        return str(self.error_msg)
22376e6818aSopenharmony_ci
22476e6818aSopenharmony_ci
22576e6818aSopenharmony_ciclass CreateUiDriverFailError(Exception):
22676e6818aSopenharmony_ci
22776e6818aSopenharmony_ci    def __init__(self, error_msg):
22876e6818aSopenharmony_ci        super(CreateUiDriverFailError, self).__init__(error_msg)
22976e6818aSopenharmony_ci        self.error_msg = error_msg
23076e6818aSopenharmony_ci
23176e6818aSopenharmony_ci    def __str__(self):
23276e6818aSopenharmony_ci        return str(self.error_msg)
23376e6818aSopenharmony_ci
23476e6818aSopenharmony_ci
23576e6818aSopenharmony_ciclass ConnectAccessibilityFailError(Exception):
23676e6818aSopenharmony_ci
23776e6818aSopenharmony_ci    def __init__(self, error_msg):
23876e6818aSopenharmony_ci        super(ConnectAccessibilityFailError, self).__init__(error_msg)
23976e6818aSopenharmony_ci        self.error_msg = error_msg
24076e6818aSopenharmony_ci
24176e6818aSopenharmony_ci    def __str__(self):
24276e6818aSopenharmony_ci        return str(self.error_msg)
24376e6818aSopenharmony_ci
24476e6818aSopenharmony_ci
24576e6818aSopenharmony_ciclass ModuleNotAttributeError(Exception):
24676e6818aSopenharmony_ci    def __init__(self, error_msg):
24776e6818aSopenharmony_ci        super(ModuleNotAttributeError, self).__init__(error_msg)
24876e6818aSopenharmony_ci        self.error_msg = error_msg
24976e6818aSopenharmony_ci
25076e6818aSopenharmony_ci    def __str__(self):
25176e6818aSopenharmony_ci        return str(self.error_msg)
25276e6818aSopenharmony_ci
25376e6818aSopenharmony_ci
25476e6818aSopenharmony_citry:
25576e6818aSopenharmony_ci    from xdevice import HdcCommandRejectedException
25676e6818aSopenharmony_ciexcept ImportError:
25776e6818aSopenharmony_ci    HdcCommandRejectedException = DeviceTestHdcCommandRejectedException
25876e6818aSopenharmony_citry:
25976e6818aSopenharmony_ci    from xdevice import \
26076e6818aSopenharmony_ci        ShellCommandUnresponsiveException
26176e6818aSopenharmony_ciexcept ImportError:
26276e6818aSopenharmony_ci    ShellCommandUnresponsiveException = \
26376e6818aSopenharmony_ci        DeviceTestShellCommandUnresponsiveException
26476e6818aSopenharmony_citry:
26576e6818aSopenharmony_ci    from xdevice import AppInstallError
26676e6818aSopenharmony_ciexcept ImportError:
26776e6818aSopenharmony_ci    AppInstallError = DeviceTestAppInstallError
26876e6818aSopenharmony_ci
26976e6818aSopenharmony_citry:
27076e6818aSopenharmony_ci    from xdevice import RpcNotRunningError
27176e6818aSopenharmony_ciexcept ImportError:
27276e6818aSopenharmony_ci    RpcNotRunningError = DeviceTestRpcNotRunningError
273