/*
 * Copyright (C) 2015 Pedro Vicente Gomez Sanchez.
 *
 * 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 com.github.pedrovgs.lynx;

import android.view.View;
import android.view.ViewGroup;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.assertEquals;

/**
 * @author Pedro Vicente Gómez Sánchez.
 */
@Config(emulateSdk = 18) @RunWith(RobolectricTestRunner.class) public class LynxActivityTest {

  private LynxActivity lynxActivity;

  @Before public void setUp() {
    lynxActivity = Robolectric.buildActivity(LynxActivity.class).create().resume().get();
  }

  @Test public void shouldShowLynxViewAsVisible() {
    LynxView lynxView = getLynxView();

    int lynxViewVisibility = lynxView.getVisibility();

    assertEquals(View.VISIBLE, lynxViewVisibility);
  }

  @Test public void shouldShowLynxViewUsingMatchParentAsConfiguration() {
    LynxView lynxView = getLynxView();

    ViewGroup.LayoutParams layoutParams = lynxView.getLayoutParams();
    int lynxViewHeight = layoutParams.height;
    int lynxViewWidth = layoutParams.width;

    assertEquals(ViewGroup.LayoutParams.MATCH_PARENT, lynxViewHeight);
    assertEquals(ViewGroup.LayoutParams.MATCH_PARENT, lynxViewWidth);
  }

  private LynxView getLynxView() {
    return (LynxView) lynxActivity.findViewById(R.id.lynx_view);
  }
}

@@ -641,16 +641,42 @@
 .lynx;%0A%0A
+import android.os.Bundle;%0A
 import a
@@ -693,16 +693,16 @@
 w.View;%0A
-
 import a
@@ -1120,16 +1120,148 @@
 Test %7B%0A%0A
+  private static final int ANY_MAX_NUMBER_OF_TRACES = 1000;%0A  private static final String EXTRA_LYNX_CONFIG = %22extra_lynx_config%22;%0A%0A
   privat
@@ -1968,16 +1968,16 @@
 eight);%0A
-
     asse
@@ -2043,16 +2043,529 @@
 );%0A  %7D%0A%0A
+  @Test public void shouldPassLynxConfigurationToLynxView() %7B%0A    LynxConfig lynxConfig = new LynxConfig().withMaxNumberOfTracesToShow(ANY_MAX_NUMBER_OF_TRACES);%0A    Bundle bundle = new Bundle();%0A    bundle.putSerializable(EXTRA_LYNX_CONFIG, lynxConfig);%0A%0A    LynxActivity lynxActivity =%0A        Robolectric.buildActivity(LynxActivity.class).create(bundle).resume().get();%0A%0A    LynxView lynxView = (LynxView) lynxActivity.findViewById(R.id.lynx_view);%0A    assertEquals(lynxConfig, lynxView.getLynxConfig());%0A  %7D%0A%0A
   privat

Add test to check if LynxActivity provides LynxConfiguration object as bundle