1 /* 2 * Copyright (C) 2019 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 17 package com.example.android.pdfrendererbasic 18 19 import androidx.arch.core.executor.testing.InstantTaskExecutorRule 20 import androidx.test.core.app.ApplicationProvider 21 import androidx.test.runner.AndroidJUnit4 22 import com.google.common.truth.Truth.assertThat 23 import org.junit.Rule 24 import org.junit.Test 25 import org.junit.runner.RunWith 26 27 @RunWith(AndroidJUnit4::class) 28 class PdfRendererBasicViewModelTest { 29 30 @get:Rule 31 val instantTaskExecutorRule = InstantTaskExecutorRule() 32 33 private val viewModel = PdfRendererBasicViewModel( 34 ApplicationProvider.getApplicationContext(), true) 35 36 @Test allPagesnull37 fun allPages() { 38 assertThat(viewModel).isNotNull() 39 assertThat(viewModel.pageInfo.value).isEqualTo(0 to 10) 40 assertThat(viewModel.previousEnabled.value).isFalse() 41 assertThat(viewModel.nextEnabled.value).isTrue() 42 assertThat(viewModel.pageBitmap.value).isNotNull() 43 repeat(9) { viewModel.showNext() } 44 assertThat(viewModel.pageInfo.value).isEqualTo(9 to 10) 45 assertThat(viewModel.previousEnabled.value).isTrue() 46 assertThat(viewModel.nextEnabled.value).isFalse() 47 assertThat(viewModel.pageBitmap.value).isNotNull() 48 } 49 50 } 51