Removing obsolete shadows

Change-Id: I9dcaa69e4e86130642be15e3585f5898dd866839
This commit is contained in:
Sunny Goyal
2020-11-13 13:48:51 -08:00
parent 2f4654ee04
commit 3751be0f1c
8 changed files with 2 additions and 230 deletions
@@ -1,15 +1,10 @@
sdk=29
shadows= \
com.android.launcher3.shadows.LShadowApplicationPackageManager \
com.android.launcher3.shadows.LShadowAppPredictionManager \
com.android.launcher3.shadows.LShadowAppWidgetManager \
com.android.launcher3.shadows.LShadowBackupManager \
com.android.launcher3.shadows.LShadowBitmap \
com.android.launcher3.shadows.LShadowDisplay \
com.android.launcher3.shadows.LShadowLauncherApps \
com.android.launcher3.shadows.LShadowTypeface \
com.android.launcher3.shadows.LShadowUserManager \
com.android.launcher3.shadows.LShadowWallpaperManager \
com.android.launcher3.shadows.ShadowDeviceFlag \
com.android.launcher3.shadows.ShadowLooperExecutor \
com.android.launcher3.shadows.ShadowMainThreadInitializedObject \
@@ -41,7 +41,6 @@ import android.os.UserManager;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.provider.RestoreDbTask;
import com.android.launcher3.shadows.LShadowBackupManager;
import com.android.launcher3.shadows.LShadowUserManager;
import com.android.launcher3.util.LauncherModelHelper;
import org.junit.Before;
@@ -51,6 +50,7 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.LooperMode;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowUserManager;
/**
* Tests to verify backup and restore flow.
@@ -68,7 +68,7 @@ public class BackupRestoreTest {
private static final int FLAG_SYSTEM = 0x00000800;
private static final int FLAG_PROFILE = 0x00001000;
private LShadowUserManager mUserManager;
private ShadowUserManager mUserManager;
private BackupManager mBackupManager;
private LauncherModelHelper mModelHelper;
private SQLiteDatabase mDb;
@@ -1,36 +0,0 @@
/*
* Copyright (C) 2020 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.launcher3.shadows;
import android.os.Process;
import android.os.UserHandle;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowApplicationPackageManager;
/**
* Shadow for {@link ShadowApplicationPackageManager} which create mock predictors
*/
@Implements(className = "android.app.ApplicationPackageManager")
public class LShadowApplicationPackageManager extends ShadowApplicationPackageManager {
@Implementation
public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user) {
return Process.myUserHandle().equals(user) ? label : "Work " + label;
}
}
@@ -1,36 +0,0 @@
/*
* Copyright (C) 2019 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.launcher3.shadows;
import android.graphics.Bitmap;
import android.graphics.Paint;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowBitmap;
/**
* Extension of {@link ShadowBitmap} with missing shadow methods
*/
@Implements(value = Bitmap.class)
public class LShadowBitmap extends ShadowBitmap {
@Implementation
protected Bitmap extractAlpha(Paint paint, int[] offsetXY) {
return extractAlpha();
}
}
@@ -1,38 +0,0 @@
/*
* Copyright (C) 2020 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.launcher3.shadows;
import android.graphics.Typeface;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowTypeface;
/**
* Extension of {@link ShadowTypeface} with missing shadow methods
*/
@Implements(Typeface.class)
public class LShadowTypeface extends ShadowTypeface {
@Implementation
public static Typeface create(Typeface family, int weight, boolean italic) {
int style = italic ? Typeface.ITALIC : Typeface.NORMAL;
if (weight >= 400) {
style |= Typeface.BOLD;
}
return create(family, style);
}
}
@@ -1,53 +0,0 @@
/*
* Copyright (C) 2019 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.launcher3.shadows;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.SparseBooleanArray;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowUserManager;
/**
* Extension of {@link ShadowUserManager} with missing shadow methods
*/
@Implements(value = UserManager.class)
public class LShadowUserManager extends ShadowUserManager {
private final SparseBooleanArray mQuietUsers = new SparseBooleanArray();
private final SparseBooleanArray mLockedUsers = new SparseBooleanArray();
@Implementation
protected boolean isQuietModeEnabled(UserHandle userHandle) {
return mQuietUsers.get(userHandle.hashCode());
}
public void setQuietModeEnabled(UserHandle userHandle, boolean enabled) {
mQuietUsers.put(userHandle.hashCode(), enabled);
}
@Implementation
protected boolean isUserUnlocked(UserHandle userHandle) {
return !mLockedUsers.get(userHandle.hashCode());
}
public void setUserLocked(UserHandle userHandle, boolean enabled) {
mLockedUsers.put(userHandle.hashCode(), enabled);
}
}
@@ -1,56 +0,0 @@
/*
* Copyright (C) 2019 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.launcher3.shadows;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import android.app.WallpaperManager;
import android.content.Context;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowUserManager;
import org.robolectric.shadows.ShadowWallpaperManager;
/**
* Extension of {@link ShadowUserManager} with missing shadow methods
*/
@Implements(WallpaperManager.class)
public class LShadowWallpaperManager extends ShadowWallpaperManager {
@Implementation
protected static WallpaperManager getInstance(Context context) {
return context.getSystemService(WallpaperManager.class);
}
/**
* Remove this once the fix for
* https://github.com/robolectric/robolectric/issues/5285
* is available
*/
public static void initializeMock() {
WallpaperManager wm = mock(WallpaperManager.class);
ShadowApplication shadowApplication = Shadows.shadowOf(RuntimeEnvironment.application);
shadowApplication.setSystemService(Context.WALLPAPER_SERVICE, wm);
doReturn(0).when(wm).getDesiredMinimumWidth();
doReturn(0).when(wm).getDesiredMinimumHeight();
}
}
@@ -19,7 +19,6 @@ import static org.mockito.Mockito.mock;
import android.app.Application;
import com.android.launcher3.shadows.LShadowWallpaperManager;
import com.android.launcher3.shadows.ShadowMainThreadInitializedObject;
import com.android.launcher3.shadows.ShadowOverrides;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
@@ -37,9 +36,6 @@ public class LauncherTestApplication extends Application implements TestLifecycl
// Disable plugins
PluginManagerWrapper.INSTANCE.initializeForTesting(mock(PluginManagerWrapper.class));
// Initialize mock wallpaper manager
LShadowWallpaperManager.initializeMock();
}
@Override