Home | History | Annotate | Download | only in stubs
      1 /*
      2  * Copyright (C) 2008 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 android.app.stubs;
     18 
     19 import android.app.LauncherActivity;
     20 import android.content.Intent;
     21 import android.os.Bundle;
     22 import android.view.View;
     23 import android.view.WindowManager;
     24 import android.widget.ListView;
     25 
     26 public class LauncherActivityStub extends LauncherActivity {
     27     public boolean isOnCreateCalled = false;
     28     public boolean isOnListItemClick = false;
     29     // For testing LauncherActivity#getTargetIntent()
     30     private Intent mSuperIntent;
     31 
     32     public Intent getSuperIntent() {
     33         return mSuperIntent;
     34     }
     35 
     36     @Override
     37     protected Intent getTargetIntent() {
     38         mSuperIntent = super.getTargetIntent();
     39         Intent targetIntent = new Intent(Intent.ACTION_MAIN, null);
     40         targetIntent.addCategory(Intent.CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST);
     41         targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     42         return targetIntent;
     43     }
     44 
     45     @Override
     46     public Intent intentForPosition(int position) {
     47         return super.intentForPosition(position);
     48     }
     49 
     50     public LauncherActivityStub() {
     51         super();
     52     }
     53 
     54     @Override
     55     protected void onCreate(Bundle savedInstanceState) {
     56         super.onCreate(savedInstanceState);
     57         isOnCreateCalled = true;
     58         getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
     59                 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
     60                 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
     61     }
     62 
     63     @Override
     64     public void onListItemClick(ListView l, View v, int position, long id) {
     65         super.onListItemClick(l, v, position, id);
     66         isOnListItemClick = true;
     67     }
     68 }
     69