Home | History | Annotate | Download | only in testcase
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.cts.verifier.p2p.testcase;
     18 
     19 import java.util.ArrayList;
     20 import java.util.List;
     21 
     22 import com.android.cts.verifier.R;
     23 
     24 import android.content.Context;
     25 import android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
     26 import android.net.wifi.p2p.nsd.WifiP2pServiceRequest;
     27 
     28 /**
     29  * Service discovery requester test case to search all UPnP and Bonjour services with
     30  * WifiP2pServiceRequest.newInstance(WifiP2pServiceInfo.SERVICE_TYPE_BONJOUR) and
     31  * WifiP2pServiceRequest.newInstance(WifiP2pServiceInfo.SERVICE_TYPE_UPNP).
     32  */
     33 public class ServReqAllTestCase02 extends ServReqTestCase {
     34 
     35     public ServReqAllTestCase02(Context context) {
     36         super(context);
     37     }
     38 
     39     @Override
     40     protected boolean executeTest() throws InterruptedException {
     41 
     42         notifyTestMsg(R.string.p2p_checking_serv_capab);
     43 
     44         /*
     45          * create request to search all services.
     46          */
     47         List<WifiP2pServiceRequest> reqList = new ArrayList<WifiP2pServiceRequest>();
     48         reqList.add(WifiP2pServiceRequest.newInstance(
     49                 WifiP2pServiceInfo.SERVICE_TYPE_BONJOUR));
     50         reqList.add(WifiP2pServiceRequest.newInstance(
     51                 WifiP2pServiceInfo.SERVICE_TYPE_UPNP));
     52 
     53         /*
     54          * search and check the callback function.
     55          *
     56          * The expected the argument of the callback function is as follows.
     57          * DNS PTR: ALL services.
     58          * DNS TXT: ALL services.
     59          * UPnP: ALL services.
     60          */
     61         return searchTest(mTargetAddress, reqList,
     62                 DnsSdResponseListenerTest.ALL_DNS_PTR,
     63                 DnsSdTxtRecordListenerTest.ALL_DNS_TXT,
     64                 UPnPServiceResponseListenerTest.ALL_UPNP_SERVICES);
     65     }
     66 
     67     @Override
     68     public String getTestName() {
     69         return "Request all services test 02";
     70     }
     71 }
     72