Implement Wi-Fi QR code scanner flow.

1. Implements WifiNetworkConfig Wi-Fi connection method
2. Shows error message when the QR code is not valid and hides it after 2s
3. In configurator mode, launchs AddDeviceFragment for a valid QR code
4. In enrollee mode, connects Wi-Fi for a valid QR code

Bug: 118794978
Test: manual test
      atest WifiQrCodetest
      atest WifiDppConfiguratorActivityTest
      atest WifiDppEnrolleeActivityTest
      atest WifiDppQrCodeScannerFragmentTest

Change-Id: Ie4731b22df295c60906156d33ea28dad9c084ce4
This commit is contained in:
Arc Wang
2018-12-27 13:54:15 +08:00
parent cc8212edf6
commit 1988fb75c6
10 changed files with 368 additions and 19 deletions

View File

@@ -80,4 +80,20 @@ public class WifiDppConfiguratorActivityTest {
assertThat(activity instanceof WifiDppQrCodeGeneratorFragment
.OnQrCodeGeneratorFragmentAddButtonClickedListener).isEqualTo(true);
}
@Test
public void testActivity_shouldImplementsOnScanWifiDppSuccessCallback() {
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
assertThat(activity instanceof WifiDppQrCodeScannerFragment
.OnScanWifiDppSuccessListener).isEqualTo(true);
}
@Test
public void testActivity_shouldImplementsOnScanZxingWifiFormatSuccessCallback() {
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
assertThat(activity instanceof WifiDppQrCodeScannerFragment
.OnScanZxingWifiFormatSuccessListener).isEqualTo(true);
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wifi.dpp;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class WifiDppEnrolleeActivityTest {
@Rule
public final ActivityTestRule<WifiDppEnrolleeActivity> mActivityRule =
new ActivityTestRule<>(WifiDppEnrolleeActivity.class);
@Test
public void testActivity_shouldImplementsOnScanWifiDppSuccessCallback() {
WifiDppEnrolleeActivity activity = mActivityRule.getActivity();
assertThat(activity instanceof WifiDppQrCodeScannerFragment
.OnScanWifiDppSuccessListener).isEqualTo(true);
}
@Test
public void testActivity_shouldImplementsOnScanZxingWifiFormatSuccessCallback() {
WifiDppEnrolleeActivity activity = mActivityRule.getActivity();
assertThat(activity instanceof WifiDppQrCodeScannerFragment
.OnScanZxingWifiFormatSuccessListener).isEqualTo(true);
}
}