Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2016 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.widget.cts;
     18 
     19 import android.app.Activity;
     20 import android.os.Bundle;
     21 import android.view.KeyEvent;
     22 import android.view.Menu;
     23 import android.widget.Toolbar;
     24 
     25 /**
     26  * A minimal application for {@link Toolbar} test.
     27  */
     28 public class ToolbarCtsActivity extends Activity {
     29     private Toolbar mMainToolbar;
     30 
     31     public int mCreateMenuCount;
     32     public int mPrepareMenuCount;
     33     public int mKeyShortcutCount;
     34 
     35     /**
     36      * Called with the activity is first created.
     37      */
     38     @Override
     39     public void onCreate(Bundle savedInstanceState) {
     40         super.onCreate(savedInstanceState);
     41         setContentView(R.layout.toolbar_layout);
     42 
     43         mMainToolbar = (Toolbar) findViewById(R.id.toolbar_main);
     44         setActionBar(mMainToolbar);
     45     }
     46 
     47     public Toolbar getMainToolbar() {
     48         return mMainToolbar;
     49     }
     50 
     51     @Override
     52     public boolean onCreateOptionsMenu(Menu menu) {
     53         ++mCreateMenuCount;
     54         return super.onCreateOptionsMenu(menu);
     55     }
     56 
     57     @Override
     58     public boolean onPrepareOptionsMenu(Menu menu) {
     59         ++mPrepareMenuCount;
     60         return super.onPrepareOptionsMenu(menu);
     61     }
     62 
     63     @Override
     64     public boolean onKeyShortcut(int keyCode, KeyEvent event) {
     65         ++mKeyShortcutCount;
     66         return super.onKeyShortcut(keyCode, event);
     67     }
     68 
     69     public void resetCounts() {
     70         mCreateMenuCount = mPrepareMenuCount = mKeyShortcutCount = 0;
     71     }
     72 }
     73 
     74