Upload basic UI files for Wi-Fi DPP Settings development.
WifiDppQrCodeScannerActivity is the activity for user to scan QR code and add device to a saved network. Bug: 118797380 Test: manual Change-Id: If2c8c5ba1620e5584fb47ba7b0ea2bc2d7acb641
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class WifiDppConfiguratorActivityTest {
|
||||
@Rule
|
||||
public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
|
||||
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
|
||||
|
||||
@Test
|
||||
public void testLaunchModeQrCodeScanner_shouldNotAutoFinish() {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
||||
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
|
||||
mActivityRule.launchActivity(intent);
|
||||
|
||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||
mActivityRule.finishActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
|
||||
// If we do not specify launch mode, the activity will finish itself right away
|
||||
Intent intent = new Intent();
|
||||
mActivityRule.launchActivity(intent);
|
||||
|
||||
assertThat(mActivityRule.getActivityResult().getResultCode()).
|
||||
isEqualTo(Activity.RESULT_CANCELED);
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class WifiDppQrCodeScannerFragmentTest {
|
||||
@Rule
|
||||
public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
|
||||
new ActivityTestRule<>(WifiDppConfiguratorActivity.class, true);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
||||
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
|
||||
mActivityRule.launchActivity(intent);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeftButton_shouldFinishActivityWithResultCodeCanceled() {
|
||||
onView(withText("Cancel")).perform(click());
|
||||
assertThat(mActivityRule.getActivityResult().getResultCode()).
|
||||
isEqualTo(Activity.RESULT_CANCELED);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user