1// CHECKSTYLE:OFF Generated code 2/* This file is auto-generated from VerticalGridFragmentTest.java. DO NOT MODIFY. */ 3 4/* 5 * Copyright (C) 2016 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20package android.support.v17.leanback.app; 21 22import android.support.v4.app.Fragment; 23import android.os.Bundle; 24import android.support.test.InstrumentationRegistry; 25import android.support.test.filters.MediumTest; 26import android.support.test.runner.AndroidJUnit4; 27import android.support.v17.leanback.widget.ArrayObjectAdapter; 28import android.support.v17.leanback.widget.VerticalGridPresenter; 29 30import org.junit.Test; 31import org.junit.runner.RunWith; 32 33@MediumTest 34@RunWith(AndroidJUnit4.class) 35public class VerticalGridSupportFragmentTest extends SingleSupportFragmentTestBase { 36 37 public static class GridFragment extends VerticalGridSupportFragment { 38 @Override 39 public void onCreate(Bundle savedInstanceState) { 40 super.onCreate(savedInstanceState); 41 if (savedInstanceState == null) { 42 prepareEntranceTransition(); 43 } 44 VerticalGridPresenter gridPresenter = new VerticalGridPresenter(); 45 gridPresenter.setNumberOfColumns(3); 46 setGridPresenter(gridPresenter); 47 setAdapter(new ArrayObjectAdapter()); 48 } 49 } 50 51 @Test 52 public void immediateRemoveFragment() throws Throwable { 53 final SingleSupportFragmentTestActivity activity = launchAndWaitActivity(GridFragment.class, 500); 54 55 InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { 56 @Override 57 public void run() { 58 GridFragment f = new GridFragment(); 59 activity.getSupportFragmentManager().beginTransaction() 60 .replace(android.R.id.content, f, null).commit(); 61 f.startEntranceTransition(); 62 activity.getSupportFragmentManager().beginTransaction() 63 .replace(android.R.id.content, new Fragment(), null).commit(); 64 } 65 }); 66 67 Thread.sleep(1000); 68 activity.finish(); 69 } 70 71} 72