<commit_before>/*
 * Copyright (C) 2017-2018 <NAME>
 *
 * 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 uk.co.samuelwall.materialtaptargetprompt;

import android.app.Activity;
import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.robolectric.shadows.support.v4.SupportFragmentTestUtil.startFragment;

@RunWith(RobolectricTestRunner.class)
@Config(constants = uk.co.samuelwall.materialtaptargetprompt.BuildConfig.class, sdk = 22)
public class BuilderUnitTest
{
    @Test
    public void testBuilder_Fragment()
    {
        final android.app.Fragment fragment = Robolectric.buildFragment(android.app.Fragment.class).create().get();
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_Fragment_Resource()
    {
        final android.app.Fragment fragment = Robolectric.buildFragment(android.app.Fragment.class).create().get();
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment, 0);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_DialogFragment()
    {
        final android.app.DialogFragment dialogFragment = spy(Robolectric.buildFragment(android.app.DialogFragment.class).create().get());
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        final Dialog dialog = mock(Dialog.class);
        when(dialogFragment.getDialog()).thenReturn(dialog);
        when(dialog.getOwnerActivity()).thenReturn(activity);
        when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content));
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(dialogFragment);
        assertTrue(builder.getResourceFinder() instanceof DialogResourceFinder);
    }

    @Test
    public void testBuilder_Dialog()
    {
        final Dialog dialog = mock(Dialog.class);
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        when(dialog.getOwnerActivity()).thenReturn(activity);
        when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content));
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(dialog);
        assertTrue(builder.getResourceFinder() instanceof DialogResourceFinder);
    }

    @Test
    public void testBuilder_Activity()
    {
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(activity);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_SupportFragment()
    {
        final Fragment fragment = new Fragment();
        startFragment(fragment);
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_SupportFragment_Resource()
    {
        final Fragment fragment = new Fragment();
        startFragment(fragment);
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment, 0);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_SupportDialogFragment()
    {
        final DialogFragment dialogFragment = spy(new DialogFragment());
        startFragment(dialogFragment);
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        final Dialog dialog = mock(Dialog.class);
        when(dialogFragment.getDialog()).thenReturn(dialog);
        when(dialog.getOwnerActivity()).thenReturn(activity);
        when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content));<commit_msg>test(builder): disable support library builder tests<commit_after>/*
 * Copyright (C) 2017-2018 <NAME>
 *
 * 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 uk.co.samuelwall.materialtaptargetprompt;

import android.app.Activity;
import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.robolectric.shadows.support.v4.SupportFragmentTestUtil.startFragment;

@RunWith(RobolectricTestRunner.class)
@Config(constants = uk.co.samuelwall.materialtaptargetprompt.BuildConfig.class, sdk = 22)
public class BuilderUnitTest
{
    @Test
    public void testBuilder_Fragment()
    {
        final android.app.Fragment fragment = Robolectric.buildFragment(android.app.Fragment.class).create().get();
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_Fragment_Resource()
    {
        final android.app.Fragment fragment = Robolectric.buildFragment(android.app.Fragment.class).create().get();
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment, 0);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    @Test
    public void testBuilder_DialogFragment()
    {
        final android.app.DialogFragment dialogFragment = spy(Robolectric.buildFragment(android.app.DialogFragment.class).create().get());
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        final Dialog dialog = mock(Dialog.class);
        when(dialogFragment.getDialog()).thenReturn(dialog);
        when(dialog.getOwnerActivity()).thenReturn(activity);
        when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content));
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(dialogFragment);
        assertTrue(builder.getResourceFinder() instanceof DialogResourceFinder);
    }

    @Test
    public void testBuilder_Dialog()
    {
        final Dialog dialog = mock(Dialog.class);
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        when(dialog.getOwnerActivity()).thenReturn(activity);
        when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content));
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(dialog);
        assertTrue(builder.getResourceFinder() instanceof DialogResourceFinder);
    }

    @Test
    public void testBuilder_Activity()
    {
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(activity);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    //@Test
    public void testBuilder_SupportFragment()
    {
        final Fragment fragment = new Fragment();
        startFragment(fragment);
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    //@Test
    public void testBuilder_SupportFragment_Resource()
    {
        final Fragment fragment = new Fragment();
        startFragment(fragment);
        final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(fragment, 0);
        assertTrue(builder.getResourceFinder() instanceof ActivityResourceFinder);
    }

    //@Test
    public void testBuilder_SupportDialogFragment()
    {
        final DialogFragment dialogFragment = spy(new DialogFragment());
        startFragment(dialogFragment);
        final Activity activity = Robolectric.buildActivity(Activity.class).create().get();
        final Dialog dialog = mock(Dialog.class);
        when(dialogFragment.getDialog()).thenReturn(dialog);
        when(dialog.getOwnerActivity()).thenReturn(activity);
        when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content));
{'fraction_non_alphanumeric': 0.09606515552938867, 'fraction_numerical': 0.0037287802963399076, 'mean_word_length': 4.308333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1120011', 'n_tokens_mistral': 2660, 'n_tokens_neox': 2615, 'n_words': 568}