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

Commit 9874b5d6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removing obsolete robo test setup" into sc-v2-dev

parents 5319444c 848e297e
Loading
Loading
Loading
Loading

robolectric_tests/Android.bp

deleted100644 → 0
+0 −62
Original line number Diff line number Diff line
// Copyright (C) 2021 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.

//
// Launcher Robolectric test target.
//
//        "robolectric_android-all-stub", not needed, we write our own stubs
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "packages_apps_Launcher3_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["packages_apps_Launcher3_license"],
}

filegroup {
    name: "launcher3-robolectric-resources",
    path: "resources",
    srcs: ["resources/*"],
}

filegroup {
    name: "launcher3-robolectric-src",
    srcs: ["src/**/*.java"],
}

android_robolectric_test {
    name: "LauncherRoboTests",
    srcs: [
        ":launcher3-robolectric-src",
    ],
    java_resources: [":launcher3-robolectric-resources"],
    static_libs: [
        "truth-prebuilt",
        "androidx.test.espresso.contrib",
        "androidx.test.espresso.core",
        "androidx.test.espresso.intents",
        "androidx.test.ext.junit",
        "androidx.test.runner",
        "androidx.test.rules",
        "mockito-robolectric-prebuilt",
        "SystemUISharedLib",
    ],
    robolectric_prebuilt_version: "4.5.1",
    instrumentation_for: "Launcher3",

    test_options: {
        timeout: 36000,
    },
}
+0 −36
Original line number Diff line number Diff line
<!--
   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.
-->
<resources>
    <!-- overlayable_icons references all of the drawables in this package
         that are being overlayed by resource overlays. If you remove/rename
         any of these resources, you must also change the resource overlay icons.-->
    <array name="overlayable_icons">
        <item>@drawable/ic_corp</item>
        <item>@drawable/ic_drag_handle</item>
        <item>@drawable/ic_hourglass_top</item>
        <item>@drawable/ic_info_no_shadow</item>
        <item>@drawable/ic_install_no_shadow</item>
        <item>@drawable/ic_palette</item>
        <item>@drawable/ic_pin</item>
        <item>@drawable/ic_remove_no_shadow</item>
        <item>@drawable/ic_setting</item>
        <item>@drawable/ic_smartspace_preferences</item>
        <item>@drawable/ic_split_screen</item>
        <item>@drawable/ic_uninstall_no_shadow</item>
        <item>@drawable/ic_warning</item>
        <item>@drawable/ic_widget</item>
    </array>
</resources>
+0 −15
Original line number Diff line number Diff line
sdk=30

shadows= \
    com.android.launcher3.shadows.LShadowAppPredictionManager \
    com.android.launcher3.shadows.LShadowAppWidgetManager \
    com.android.launcher3.shadows.LShadowBackupManager \
    com.android.launcher3.shadows.LShadowDisplay \
    com.android.launcher3.shadows.LShadowLauncherApps \
    com.android.launcher3.shadows.ShadowDeviceFlag \
    com.android.launcher3.shadows.ShadowLooperExecutor \
    com.android.launcher3.shadows.ShadowMainThreadInitializedObject \
    com.android.launcher3.shadows.ShadowOverrides \
    com.android.launcher3.shadows.ShadowSurfaceTransactionApplier \

application=com.android.launcher3.util.LauncherTestApplication
+0 −38
Original line number Diff line number Diff line
/*
 * 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 static org.mockito.Mockito.mock;

import android.app.prediction.AppPredictionContext;
import android.app.prediction.AppPredictionManager;
import android.app.prediction.AppPredictor;

import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;

/**
 * Shadow for {@link AppPredictionManager} which create mock predictors
 */
@Implements(value = AppPredictionManager.class)
public class LShadowAppPredictionManager {

    @Implementation
    public AppPredictor createAppPredictionSession(AppPredictionContext predictionContext) {
        return mock(AppPredictor.class);
    }
}
+0 −48
Original line number Diff line number Diff line
/*
 * 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.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.os.Process;
import android.os.UserHandle;

import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowAppWidgetManager;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Extension of {@link ShadowAppWidgetManager} with missing shadow methods
 */
@Implements(value = AppWidgetManager.class)
public class LShadowAppWidgetManager extends ShadowAppWidgetManager {

    @Override
    protected List<AppWidgetProviderInfo> getInstalledProviders() {
        return getInstalledProvidersForProfile(null);
    }

    @Implementation
    public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(UserHandle profile) {
        UserHandle user = profile == null ? Process.myUserHandle() : profile;
        return super.getInstalledProviders().stream().filter(
                info -> user.equals(info.getProfile())).collect(Collectors.toList());
    }
}
Loading