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

Commit 1e916de9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add unit tests for database migration"

parents 7cc94744 38e4c2f1
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \
        androidx.core_core \
        androidx.lifecycle_lifecycle-livedata \
        androidx.room_room-runtime \
        bt-androidx-room-runtime-nodeps \

LOCAL_ANNOTATION_PROCESSORS := \
        bt-androidx-annotation-nodeps \
@@ -45,7 +46,11 @@ LOCAL_ANNOTATION_PROCESSORS := \
        bt-sqlite-jdbc-nodeps \
        bt-jetbrain-nodeps \
        guava-21.0 \
        kotlin-stdlib
        kotlin-stdlib \
        gson-prebuilt-jar

LOCAL_JAVACFLAGS := \
        -Aroom.schemaLocation=$(LOCAL_PATH)/tests/unit/src/com/android/bluetooth/btservice/storage/schemas

LOCAL_ANNOTATION_PROCESSOR_CLASSES := \
        androidx.room.RoomProcessor
@@ -66,6 +71,7 @@ LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
        bt-androidx-room-common-nodeps:$(ROOM_LIBS_PATH)/room-common-2.0.0-beta01.jar \
        bt-androidx-room-compiler-nodeps:$(ROOM_LIBS_PATH)/room-compiler-2.0.0-beta01.jar \
        bt-androidx-room-migration-nodeps:$(ROOM_LIBS_PATH)/room-migration-2.0.0-beta01.jar \
        bt-androidx-room-runtime-nodeps:$(ROOM_LIBS_PATH)/room-runtime-2.0.0-alpha1.aar \
        bt-antlr4-nodeps:$(COMMON_LIBS_PATH)/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar \
        bt-apache-commons-codec-nodeps:$(COMMON_LIBS_PATH)/org/eclipse/tycho/tycho-bundles-external/0.18.1/eclipse/plugins/org.apache.commons.codec_1.4.0.v201209201156.jar \
        bt-auto-common-nodeps:$(COMMON_LIBS_PATH)/com/google/auto/auto-common/0.9/auto-common-0.9.jar \
+52.1 KiB

File added.

No diff preview for this file type.

+10.8 KiB

File added.

No diff preview for this file type.

+7 −3
Original line number Diff line number Diff line
@@ -24,12 +24,14 @@ import androidx.room.RoomDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

import com.android.internal.annotations.VisibleForTesting;

import java.util.List;

/**
 * MetadataDatabase is a Room database stores Bluetooth persistence data
 */
@Database(entities = {Metadata.class}, exportSchema = false, version = 102)
@Database(entities = {Metadata.class}, version = 102)
public abstract class MetadataDatabase extends RoomDatabase {
    /**
     * The database file name
@@ -100,14 +102,16 @@ public abstract class MetadataDatabase extends RoomDatabase {
        mMetadataDao().deleteAll();
    }

    private static final Migration MIGRATION_100_101 = new Migration(100, 101) {
    @VisibleForTesting
    static final Migration MIGRATION_100_101 = new Migration(100, 101) {
        @Override
        public void migrate(SupportSQLiteDatabase database) {
            database.execSQL("ALTER TABLE metadata ADD COLUMN `pbap_client_priority` INTEGER");
        }
    };

    private static final Migration MIGRATION_101_102 = new Migration(101, 102) {
    @VisibleForTesting
    static final Migration MIGRATION_101_102 = new Migration(101, 102) {
        @Override
        public void migrate(SupportSQLiteDatabase database) {
            database.execSQL("CREATE TABLE IF NOT EXISTS `metadata_tmp` ("
+19 −1
Original line number Diff line number Diff line
@@ -17,7 +17,14 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
    com.android.emailcommon \
    androidx.test.rules \
    mockito-target \
    androidx.test.espresso.intents
    androidx.test.espresso.intents \
    gson-prebuilt-jar \
    bt-androidx-room-migration-nodeps \
    bt-androidx-room-runtime-nodeps \
    bt-androidx-room-testing-nodeps

LOCAL_ASSET_DIR += \
    $(LOCAL_PATH)/src/com/android/bluetooth/btservice/storage/schemas

# Include all test java files.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -30,3 +37,14 @@ LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_INSTRUMENTATION_FOR := Bluetooth

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)

ROOM_LIBS_PATH := ../../lib/room

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
    bt-androidx-room-migration-nodeps:$(ROOM_LIBS_PATH)/room-migration-2.0.0-beta01.jar \
    bt-androidx-room-runtime-nodeps:$(ROOM_LIBS_PATH)/room-runtime-2.0.0-alpha1.aar \
    bt-androidx-room-testing-nodeps:$(ROOM_LIBS_PATH)/room-testing-2.0.0-alpha1.aar

include $(BUILD_MULTI_PREBUILT)
Loading