|
Android example source code file (TestBrowserActivity.java)
The TestBrowserActivity.java Android example source code/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.test; import com.android.internal.R; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import junit.framework.Test; import junit.framework.TestSuite; import java.util.List; /** * @hide - This is part of a framework that is under development and should not be used for * active development. */ public abstract class TestBrowserActivity extends ListActivity implements android.test.TestBrowserView, AdapterView.OnItemClickListener, TestSuiteProvider { private TestBrowserController mTestBrowserController; public static final String BUNDLE_EXTRA_PACKAGE = "package"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getListView().setOnItemClickListener(this); mTestBrowserController = ServiceLocator.getTestBrowserController(); mTestBrowserController.setTargetPackageName(getPackageName()); mTestBrowserController.registerView(this); mTestBrowserController.setTargetBrowserActivityClassName(this.getClass().getName()); // Apk paths used to search for test classes when using TestSuiteBuilders. String[] apkPaths = {getPackageCodePath()}; ClassPathPackageInfoSource.setApkPaths(apkPaths); } @Override protected void onStart() { super.onStart(); TestSuite testSuite = getTestSuiteToBrowse(); mTestBrowserController.setTestSuite(testSuite); String name = testSuite.getName(); if (name != null) { setTitle(name.substring(name.lastIndexOf(".") + 1)); } } /** * Subclasses will override this method and return the TestSuite specific to their .apk. * When this method is invoked due to an intent fired from * {@link #onItemClick(android.widget.AdapterView, android.view.View, int, long)} then get the * targeted TestSuite from the intent. * * @return testSuite to browse */ @SuppressWarnings("unchecked") private TestSuite getTestSuiteToBrowse() { Intent intent = getIntent(); if (Intent.ACTION_RUN.equals(intent.getAction())) { String testClassName = intent.getData().toString(); try { Class<Test> testClass = (Class Other Android examples (source code examples)Here is a short list of links related to this Android TestBrowserActivity.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.