Fix failing testcases in SettingsAdapterTest.
- added the shadow class for CardView to fix the not implemented error. Change-Id: I17a53f804310ffb3330c1cd3ca11943cf91335a6 Fixes: 74446970 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -44,23 +44,25 @@ import com.android.settings.SettingsActivity;
|
|||||||
import com.android.settings.dashboard.DashboardAdapter;
|
import com.android.settings.dashboard.DashboardAdapter;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowCardView;
|
||||||
import com.android.settingslib.suggestions.SuggestionControllerMixin;
|
import com.android.settingslib.suggestions.SuggestionControllerMixin;
|
||||||
import com.android.settingslib.utils.IconCache;
|
import com.android.settingslib.utils.IconCache;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Answers;
|
import org.mockito.Answers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(shadows = ShadowCardView.class)
|
||||||
public class SuggestionAdapterTest {
|
public class SuggestionAdapterTest {
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
@@ -143,7 +145,6 @@ public class SuggestionAdapterTest {
|
|||||||
.isEqualTo(R.layout.suggestion_tile_with_button);
|
.isEqualTo(R.layout.suggestion_tile_with_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_shouldLog() {
|
public void onBindViewHolder_shouldLog() {
|
||||||
final View view = spy(LayoutInflater.from(mContext).inflate(
|
final View view = spy(LayoutInflater.from(mContext).inflate(
|
||||||
@@ -164,7 +165,6 @@ public class SuggestionAdapterTest {
|
|||||||
mOneSuggestion.get(0).getId());
|
mOneSuggestion.get(0).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_itemViewShouldHandleClick()
|
public void onBindViewHolder_itemViewShouldHandleClick()
|
||||||
throws PendingIntent.CanceledException {
|
throws PendingIntent.CanceledException {
|
||||||
@@ -178,7 +178,6 @@ public class SuggestionAdapterTest {
|
|||||||
verify(suggestions.get(0).getPendingIntent()).send();
|
verify(suggestions.get(0).getPendingIntent()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_hasButton_buttonShouldHandleClick()
|
public void onBindViewHolder_hasButton_buttonShouldHandleClick()
|
||||||
throws PendingIntent.CanceledException {
|
throws PendingIntent.CanceledException {
|
||||||
@@ -205,7 +204,6 @@ public class SuggestionAdapterTest {
|
|||||||
verify(pendingIntent).send();
|
verify(pendingIntent).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void getSuggestions_shouldReturnSuggestionWhenMatch() {
|
public void getSuggestions_shouldReturnSuggestionWhenMatch() {
|
||||||
final List<Suggestion> suggestions = makeSuggestions("pkg1");
|
final List<Suggestion> suggestions = makeSuggestions("pkg1");
|
||||||
@@ -214,7 +212,6 @@ public class SuggestionAdapterTest {
|
|||||||
assertThat(mSuggestionAdapter.getSuggestion(0)).isNotNull();
|
assertThat(mSuggestionAdapter.getSuggestion(0)).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_closeButtonShouldHandleClick()
|
public void onBindViewHolder_closeButtonShouldHandleClick()
|
||||||
throws PendingIntent.CanceledException {
|
throws PendingIntent.CanceledException {
|
||||||
@@ -236,7 +233,6 @@ public class SuggestionAdapterTest {
|
|||||||
verify(callback).onSuggestionClosed(suggestion);
|
verify(callback).onSuggestionClosed(suggestion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
|
public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
|
||||||
throws PendingIntent.CanceledException {
|
throws PendingIntent.CanceledException {
|
||||||
@@ -263,7 +259,6 @@ public class SuggestionAdapterTest {
|
|||||||
verify(drawable, never()).setTint(anyInt());
|
verify(drawable, never()).setTint(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_iconTintable_shouldTintIcon()
|
public void onBindViewHolder_iconTintable_shouldTintIcon()
|
||||||
throws PendingIntent.CanceledException {
|
throws PendingIntent.CanceledException {
|
||||||
@@ -296,7 +291,6 @@ public class SuggestionAdapterTest {
|
|||||||
verify(drawable).setTint(colorAccent);
|
verify(drawable).setTint(colorAccent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_closeButtonShouldHaveContentDescription()
|
public void onBindViewHolder_closeButtonShouldHaveContentDescription()
|
||||||
throws PendingIntent.CanceledException {
|
throws PendingIntent.CanceledException {
|
||||||
@@ -310,7 +304,6 @@ public class SuggestionAdapterTest {
|
|||||||
.isNotNull();
|
.isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void setCardLayout_twoCards_shouldSetCardWidthToHalfScreenMinusPadding() {
|
public void setCardLayout_twoCards_shouldSetCardWidthToHalfScreenMinusPadding() {
|
||||||
final List<Suggestion> suggestions = makeSuggestions("pkg1");
|
final List<Suggestion> suggestions = makeSuggestions("pkg1");
|
||||||
|
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.testutils.shadow;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.robolectric.annotation.Implements;
|
||||||
|
import org.robolectric.shadows.ShadowFrameLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shadow for CardView to get around view not implemented error.
|
||||||
|
*/
|
||||||
|
@Implements(CardView.class)
|
||||||
|
public class ShadowCardView extends ShadowFrameLayout {
|
||||||
|
|
||||||
|
public void __constructor__(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user