/* * Copyright (c) 2015, Ericsson AB. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ package com.ericsson.research.owr.sdk; import android.app.Activity; import android.app.KeyguardManager; import android.content.Context; import android.os.Bundle; import android.test.ActivityInstrumentationTestCase2; import android.util.Log; import android.view.TextureView; import android.view.WindowManager; import com.ericsson.research.owr.Owr; public class OwrActivityTestCase extends ActivityInstrumentationTestCase2<OwrActivityTestCase.TextureViewTestActivity> { private static final String TAG = "OwrTestCase"; static { Owr.init(); } public OwrActivityTestCase() { super(TextureViewTestActivity.class); } @Override protected void setUp() throws Exception { super.setUp(); Log.v(TAG, "running owr main loop in background"); Owr.runInBackground(); } @Override protected void tearDown() throws Exception { super.tearDown(); Log.v(TAG, "quitting owr main loop"); Owr.quit(); } public static class TextureViewTestActivity extends Activity { private TextureView mTextureView; public TextureViewTestActivity() { } public TextureView getTextureView() { return mTextureView; } @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTextureView = new TextureView(this); setContentView(mTextureView); KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); KeyguardManager.KeyguardLock keyguardLock = km.newKeyguardLock("TAG"); keyguardLock.disableKeyguard(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); } } }