1#!/usr/bin/env python
2#
3# Copyright (C) 2018 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18import unittest
19import vts.utils.python.controllers.android_device as android_device
20
21
22class AndroidDeviceTest(unittest.TestCase):
23    '''Test methods inside android_device module.'''
24
25    def setUp(self):
26        """SetUp tasks"""
27        available_serials = android_device.list_adb_devices()
28        self.assertGreater(len(available_serials), 0, 'no device available.')
29        self.dut = android_device.AndroidDevice(available_serials[0])
30
31    def tearDown(self):
32        """TearDown tasks"""
33        pass
34
35    def testFrameworkStatusChange(self):
36        '''Test AndroidDevice class startRuntime related functions.'''
37        err_msg = 'Runtime status is wrong'
38        print('step 1 start runtime')
39        self.dut.start()
40
41        print('step 2 check runtime status')
42        self.assertTrue(self.dut.isFrameworkRunning(), err_msg)
43
44        print('step 3 stop runtime')
45        self.dut.stop()
46
47        print('step 4 check runtime status')
48        self.assertFalse(self.dut.isFrameworkRunning(), err_msg)
49
50        print('step 5 start runtime')
51        self.dut.start()
52
53        print('step 6 check runtime status')
54        self.assertTrue(self.dut.isFrameworkRunning(), err_msg)
55
56
57if __name__ == "__main__":
58    unittest.main()
59