Merge "Merge "Use support feature provider to provide intro url." into oc-dr1-dev am: bdc0816982" into oc-dr1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
afa34b1cc4
@@ -1,20 +0,0 @@
|
||||
<!--
|
||||
Copyright (C) 2017 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- url for new device suggestion -->
|
||||
<string name="new_device_suggestion_intro_url" translatable="false">http://www.com.android.settings.test.com</string>
|
||||
</resources>
|
@@ -22,7 +22,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -82,32 +81,27 @@ public class NewDeviceIntroSuggestionActivityTest {
|
||||
|
||||
@Test
|
||||
public void isSuggestionComplete_noUrl_shouldReturnTrue() {
|
||||
assertThat(mContext.getString(R.string.new_device_suggestion_intro_url))
|
||||
.isEqualTo("");
|
||||
when(mFeatureFactory.supportFeatureProvider.getNewDeviceIntroUrl(any(Context.class)))
|
||||
.thenReturn(null);
|
||||
assertThat(isSuggestionComplete(mContext))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
// Use a non-default resource qualifier to load the test string in
|
||||
// res/values-mcc999/strings.xml.
|
||||
@Config(qualifiers = "mcc999")
|
||||
@Test
|
||||
public void isSuggestionComplete_alreadyLaunchedBefore_shouldReturnTrue() {
|
||||
assertThat(mContext.getString(R.string.new_device_suggestion_intro_url))
|
||||
.startsWith("http");
|
||||
when(mFeatureFactory.supportFeatureProvider.getNewDeviceIntroUrl(any(Context.class)))
|
||||
.thenReturn("https://com.android.settings");
|
||||
|
||||
getSharedPreferences().edit().putBoolean(PREF_KEY_SUGGGESTION_COMPLETE, true).commit();
|
||||
|
||||
assertThat(isSuggestionComplete(mContext))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
// Use a non-default resource qualifier to load the test string in
|
||||
// res/values-mcc999/strings.xml.
|
||||
@Config(qualifiers = "mcc999")
|
||||
@Test
|
||||
public void isSuggestionComplete_notExpiredAndCanOpenUrlInBrowser_shouldReturnFalse() {
|
||||
assertThat(mContext.getString(R.string.new_device_suggestion_intro_url))
|
||||
.startsWith("http");
|
||||
when(mFeatureFactory.supportFeatureProvider.getNewDeviceIntroUrl(any(Context.class)))
|
||||
.thenReturn("https://com.android.settings");
|
||||
|
||||
final Intent intent = NewDeviceIntroSuggestionActivity.getLaunchIntent(mContext);
|
||||
mRobolectricPackageManager.addResolveInfoForIntent(intent, new ResolveInfo());
|
||||
|
Reference in New Issue
Block a user