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.server.wm; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.view.KeyEvent; 22 import android.view.Menu; 23 import android.view.Window; 24 25 import android.server.wm.cts.R; 26 27 public class WindowCtsActivity extends Activity { 28 29 private static boolean mIsOnCreateOptionsMenuCalled; 30 private static boolean mIsOnOptionsMenuClosedCalled; 31 private static boolean mIsOnKeyDownCalled; 32 33 @Override 34 protected void onCreate(Bundle savedInstanceState) { 35 super.onCreate(savedInstanceState); 36 getWindow().requestFeature(Window.FEATURE_LEFT_ICON); 37 setContentView(R.layout.windowstub_layout); 38 } 39 40 @Override 41 public boolean onCreateOptionsMenu(Menu menu) { 42 menu.add(Menu.NONE, Menu.NONE, Menu.NONE, "Quit").setShortcut('1', 'q'); 43 menu.add(Menu.NONE, Menu.NONE, Menu.NONE, "Action").setShortcut('2', 'a'); 44 mIsOnCreateOptionsMenuCalled = true; 45 return super.onCreateOptionsMenu(menu); 46 } 47 48 @Override 49 public void onOptionsMenuClosed(Menu menu) { 50 super.onOptionsMenuClosed(menu); 51 mIsOnOptionsMenuClosedCalled = true; 52 } 53 54 @Override 55 public boolean onKeyDown(int keyCode, KeyEvent event) { 56 mIsOnKeyDownCalled = true; 57 return super.onKeyDown(keyCode, event); 58 } 59 60 public boolean isOnCreateOptionsMenuCalled() { 61 return mIsOnCreateOptionsMenuCalled; 62 } 63 64 public boolean isOnOptionsMenuClosedCalled() { 65 return mIsOnOptionsMenuClosedCalled; 66 } 67 68 public boolean isOnKeyDownCalled() { 69 return mIsOnKeyDownCalled; 70 } 71 72 public void setFlagFalse() { 73 mIsOnCreateOptionsMenuCalled = false; 74 mIsOnOptionsMenuClosedCalled = false; 75 } 76 } 77