// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.android_webview.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.LinearLayout;

/*
 * This is a lightweight activity for tests that only require WebView functionality.
 */
public class AwTestRunnerActivity extends Activity {

    private LinearLayout mLinearLayout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // TODO(joth): When SW-renderer is available, we'll want to enable this on a per-test
        // basis.
        boolean hardwareAccelerated = true;
        Log.i("AwTestRunnerActivity", "Is " + (hardwareAccelerated ? "" : "NOT ")
                + "hardware accelerated");

        if (hardwareAccelerated) {
            getWindow().setFlags(
                    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        }

        mLinearLayout = new LinearLayout(this);
        mLinearLayout.setOrientation(LinearLayout.VERTICAL);
        mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        mLinearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

        setContentView(mLinearLayout);
    }

    public int getRootLayoutWidth() {
        return mLinearLayout.getWidth();
    }

    /**
     * Adds a view to the main linear layout.
     */
    public void addView(View view) {
        view.setLayoutParams(new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));
        mLinearLayout.addView(view);
    }

    /**
     * Clears the main linear layout.
     */
    public void removeAllViews() {
        mLinearLayout.removeAllViews();
    }
}

@@ -733,519 +733,8 @@
 );%0A%0A
-        // TODO(joth): When SW-renderer is available, we'll want to enable this on a per-test%0A        // basis.%0A        boolean hardwareAccelerated = true;%0A        Log.i(%22AwTestRunnerActivity%22, %22Is %22 + (hardwareAccelerated ? %22%22 : %22NOT %22)%0A                + %22hardware accelerated%22);%0A%0A        if (hardwareAccelerated) %7B%0A            getWindow().setFlags(%0A                    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,%0A                    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);%0A        %7D%0A%0A
     
@@ -777,16 +777,16 @@
 (this);%0A
+
         
@@ -979,25 +979,25 @@
 tParams.
-WRAP_CONT
+MATCH_PAR
 ENT,%0A   
@@ -1026,17 +1026,17 @@
 ams.
-WRAP_CONT
+MATCH_PAR
 ENT)

Make tests draw something other than white.