blob: 6223760309c0fb535caf4372be0656573024ed9c [file] [log] [blame]
Pinyao Ting9be1cfd2020-01-16 12:29:04 -08001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher3.model;
18
19import static com.android.launcher3.LauncherSettings.Favorites.BACKUP_TABLE_NAME;
20import static com.android.launcher3.provider.LauncherDbUtils.tableExists;
21
22import static org.junit.Assert.assertTrue;
23
24import android.database.sqlite.SQLiteDatabase;
25
Sunny Goyalc0e9df62020-01-16 14:54:36 -080026import com.android.launcher3.provider.RestoreDbTask;
Pinyao Ting9be1cfd2020-01-16 12:29:04 -080027import com.android.launcher3.util.LauncherModelHelper;
28import com.android.launcher3.util.LauncherRoboTestRunner;
29
30import org.junit.Before;
31import org.junit.Test;
32import org.junit.runner.RunWith;
Sunny Goyalc0e9df62020-01-16 14:54:36 -080033import org.robolectric.RuntimeEnvironment;
Pinyao Ting9be1cfd2020-01-16 12:29:04 -080034import org.robolectric.annotation.LooperMode;
35
36/**
37 * Tests to verify backup and restore flow.
38 */
39@RunWith(LauncherRoboTestRunner.class)
40@LooperMode(LooperMode.Mode.PAUSED)
41public class BackupRestoreTest {
42
43 private LauncherModelHelper mModelHelper;
44 private SQLiteDatabase mDb;
45
46 @Before
47 public void setUp() {
48 mModelHelper = new LauncherModelHelper();
Sunny Goyalc0e9df62020-01-16 14:54:36 -080049 RestoreDbTask.setPending(RuntimeEnvironment.application, true);
50 mDb = mModelHelper.provider.getDb();
Pinyao Ting9be1cfd2020-01-16 12:29:04 -080051 }
52
53 @Test
54 public void testOnCreateDbIfNotExists_CreatesBackup() {
55 assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));
56 }
57}