df29723699f39a6010ed7a5ad4f219697d81240c
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / runtime_shell / src / org / xwalk / runtime / test / XWalkRuntimeTestRunnerActivity.java
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.xwalk.runtime.test;
6
7 import android.app.Activity;
8 import android.os.Bundle;
9 import android.util.Log;
10 import android.view.View;
11 import android.view.ViewGroup.LayoutParams;
12 import android.view.WindowManager;
13 import android.widget.LinearLayout;
14
15 /*
16  * This is a lightweight activity for tests that only require XWalk functionality.
17  */
18 public class XWalkRuntimeTestRunnerActivity extends Activity {
19
20     private LinearLayout mLinearLayout;
21
22     @Override
23     public void onCreate(Bundle savedInstanceState) {
24         super.onCreate(savedInstanceState);
25
26         boolean hardwareAccelerated = true;
27
28         if (hardwareAccelerated) {
29             getWindow().setFlags(
30                     WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
31                     WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
32         }
33
34         mLinearLayout = new LinearLayout(this);
35         mLinearLayout.setOrientation(LinearLayout.VERTICAL);
36         mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
37         mLinearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
38                 LayoutParams.WRAP_CONTENT));
39
40         setContentView(mLinearLayout);
41     }
42
43     /**
44      * Adds a view to the main linear layout.
45      */
46     public void addView(View view) {
47         view.setLayoutParams(new LinearLayout.LayoutParams(
48                 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));
49         mLinearLayout.addView(view);
50     }
51
52     /**
53      * Clears the main linear layout.
54      */
55     public void removeAllViews() {
56         mLinearLayout.removeAllViews();
57     }
58 }