• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3# Copyright (C) 2016 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy of
7# 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, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17from queue import Empty
18from acts.base_test import BaseTestClass
19from acts.test_utils.wifi.wifi_test_utils import wifi_toggle_state
20from acts.test_utils.wifi.wifi_test_utils import WifiEnums
21
22class Sl4aSanityTest(BaseTestClass):
23    """Tests for sl4a basic sanity.
24
25    Run these tests individually with option -r 100.
26    """
27
28    def __init__(self, controllers):
29        BaseTestClass.__init__(self, controllers)
30        self.tests = (
31            "test_bring_up_and_shutdown",
32            "test_message_then_shutdown_stress"
33        )
34
35    def test_bring_up_and_shutdown(self):
36        """Constantly start and terminate sl4a sessions.
37
38        Verify in log that the "manager map key" is always empty before a
39        session starts.
40        Verify in log by looking at timestamps that after the test finishes, no
41        more message regarding sl4a happens.
42        """
43        ad = self.android_devices[0]
44        for i in range(100):
45            self.log.info("Iteration %d, terminating." % i)
46            ad.terminate_all_sessions()
47            self.log.info("Iteration %d, starting." % i)
48            droid, ed = ad.get_droid()
49        return True
50
51    def test_message_then_shutdown_stress(self):
52        ad = self.android_devices[0]
53        for i in range(10):
54            assert wifi_toggle_state(ad.droid, ad.ed, False)
55            assert wifi_toggle_state(ad.droid, ad.ed, True)
56        return True
57