package com.mobify.astro;

import android.content.Intent;
import android.net.Uri;
import android.support.test.rule.ActivityTestRule;

import com.mobify.astro.messaging.EventManager;
import com.mobify.astro.messaging.MessageSender;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.mock;

public class AstroApplicationIntentTest {
    @Rule
    public ActivityTestRule mActivityRule = new ActivityTestRule<>(TestActivity.class,
            /* initialTouchMode */ true,
            /* launchActivity */ false);

    AstroApplication application;
    Intent launchIntent = new Intent(Intent.ACTION_MAIN);
    EventManager mockEventManager;
    MessageSender mockMessageSender;

    private AstroActivity getActivity() {
        return (AstroActivity)mActivityRule.getActivity();
    }

    @Before
    public void setup() {
        Intent intent = new Intent();
        intent.setData(Uri.parse("http://www.mobify.com"));
        launchIntent = intent;

        mActivityRule.launchActivity(launchIntent);
        mockEventManager = mock(EventManager.class);
        mockMessageSender = mock(MessageSender.class);

        application = new AstroApplication(getActivity(), mockEventManager, mockMessageSender);
    }

    @Test
    public void testGetStartUriWithUri() {
        String uri = application.getStartUri();
        assertEquals("http://www.mobify.com", uri);
    }
}
