Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9d0590b authored by Peter_Liang's avatar Peter_Liang
Browse files

Fixing the SettingsRoboTest failure of the AnimatedImagePreference.

Root cause:
Seem to need lottie raw resource when inflating the LottieAnimationView.

Action:
Use the mock for LottieAnimationView to avoid init when inflating the layout.

Bug: 191251677
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AnimatedImagePreferenceTest
Change-Id: I0197442e5a65b40142b128f28a1c6bcd7cd3a0bd
parent 49bf60df
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@ import android.graphics.drawable.AnimatedImageDrawable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimationDrawable;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.preference.PreferenceViewHolder;
@@ -45,6 +44,7 @@ import com.airbnb.lottie.LottieAnimationView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.robolectric.RobolectricTestRunner;
@@ -57,10 +57,12 @@ import java.io.InputStream;
public class AnimatedImagePreferenceTest {
    private final Context mContext = RuntimeEnvironment.application;
    private Uri mImageUri;
    private View mRootView;
    private PreferenceViewHolder mViewHolder;
    private AnimatedImagePreference mAnimatedImagePreference;

    @Mock
    private ViewGroup mRootView;

    @Spy
    private ImageView mImageView;

@@ -68,9 +70,8 @@ public class AnimatedImagePreferenceTest {
    public void init() {
        MockitoAnnotations.initMocks(this);

        final LayoutInflater inflater = LayoutInflater.from(mContext);
        mRootView = spy(inflater.inflate(R.layout.preference_animated_image, /* root= */ null));
        mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(mRootView));
        doReturn(new LottieAnimationView(mContext)).when(mRootView).findViewById(R.id.lottie_view);
        mImageView = spy(new ImageView(mContext));

        mAnimatedImagePreference = new AnimatedImagePreference(mContext);