• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 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
17import time
18
19from acts.test_decorators import test_tracker_info
20from acts_contrib.test_utils.wifi.p2p.WifiP2pBaseTest import WifiP2pBaseTest
21from acts_contrib.test_utils.wifi.p2p import wifi_p2p_test_utils as wp2putils
22from acts_contrib.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts
23
24
25class WifiP2pLocalServiceTest(WifiP2pBaseTest):
26    """Tests for APIs in Android's WifiP2pManager and p2p local service class.
27
28    Test Bed Requirement:
29    * At least two Android devices
30    * 3 Android devices for WifiP2pMultiPeersTest.py
31    """
32    def __init__(self, controllers):
33        WifiP2pBaseTest.__init__(self, controllers)
34
35    """Test Cases"""
36    @test_tracker_info(uuid="ba879c8d-0fbd-41fb-805c-5cd1cd312090")
37    def test_p2p_upnp_service(self):
38        """Verify the p2p discovery functionality
39        Steps:
40        1. dut1 add local Upnp service
41        2. dut2 register Upnp Service listener
42        3. Check dut2 peer list if it only included dut1
43        4. Setup p2p upnp local service request with different query string
44        5. Check p2p upnp local servier query result is expect or not
45        6. Test different query string and check query result
46        Note: Step 2 - Step 5 should reference function requestServiceAndCheckResult
47        """
48        self.log.info("Add local Upnp Service")
49        wp2putils.createP2pLocalService(self.dut1,
50                                        p2pconsts.P2P_LOCAL_SERVICE_UPNP)
51
52        wp2putils.requestServiceAndCheckResult(
53            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
54            WIFI_P2P_SERVICE_TYPE_UPNP, None, None)
55        time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME)
56        wp2putils.requestServiceAndCheckResult(
57            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
58            WIFI_P2P_SERVICE_TYPE_UPNP, "ssdp:all", None)
59        time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME)
60        wp2putils.requestServiceAndCheckResult(
61            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
62            WIFI_P2P_SERVICE_TYPE_UPNP, "upnp:rootdevice", None)
63        time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME)
64
65    """Test Cases"""
66    @test_tracker_info(uuid="470306fa-5c46-4258-ade2-9c0834bb04f9")
67    def test_p2p_bonjour_service(self):
68        """Verify the p2p discovery functionality
69        Steps:
70        1. dut1 add local bonjour service - IPP and AFP
71        2. dut2 register bonjour Service listener - dnssd and dnssd_txrecord
72        3. Check dut2 peer list if it only included dut1
73        4. Setup p2p bonjour local service request with different query string
74        5. Check p2p bonjour local servier query result is expect or not
75        6. Test different query string and check query result
76        Note: Step 2 - Step 5 should reference function requestServiceAndCheckResult
77        """
78        self.log.info("Add local bonjour service to %s" % (self.dut1.name))
79        wp2putils.createP2pLocalService(self.dut1,
80                                        p2pconsts.P2P_LOCAL_SERVICE_IPP)
81        wp2putils.createP2pLocalService(self.dut1,
82                                        p2pconsts.P2P_LOCAL_SERVICE_AFP)
83
84        wp2putils.requestServiceAndCheckResultWithRetry(
85            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
86            WIFI_P2P_SERVICE_TYPE_BONJOUR, None, None)
87        time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME)
88        wp2putils.requestServiceAndCheckResultWithRetry(
89            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
90            WIFI_P2P_SERVICE_TYPE_BONJOUR, "_ipp._tcp", None)
91        time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME)
92        wp2putils.requestServiceAndCheckResultWithRetry(
93            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
94            WIFI_P2P_SERVICE_TYPE_BONJOUR, "_ipp._tcp", "MyPrinter")
95        time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME)
96        wp2putils.requestServiceAndCheckResultWithRetry(
97            self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo.
98            WIFI_P2P_SERVICE_TYPE_BONJOUR, "_afpovertcp._tcp", "Example")
99