Repository navigation
install-tor.sh #3532
Description
import android.content.Context;
import android.content.Intent;
import android.widget.TextView;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.core.app.ActivityScenario;
import com.google.assistant.appactions.testing.aatl.AppActionsTestManager;
import com.google.assistant.appactions.testing.aatl.fulfillment.AppActionsFulfillmentIntentResult;
import com.google.assistant.appactions.testing.aatl.fulfillment.AppActionsFulfillmentResult;
import com.google.assistant.appactions.testing.aatl.fulfillment.FulfillmentType;
import com.google.common.collect.ImmutableMap;
import org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.Test;
import org.robolectric.RobolectricTestRunner;
...
@test
public void IntentTestExample() throws Exception {
Map<String, String> intentParams = ImmutableMap.of("feature", "settings");
String intentName = "actions.intent.OPEN_APP_FEATURE";
AppActionsFulfillmentResult result = aatl.fulfill(intentName, intentParams);
assertEquals(FulfillmentType.INTENT, result.getFulfillmentType());
AppActionsFulfillmentIntentResult intentResult = (AppActionsFulfillmentIntentResult) result;
Intent intent = intentResult.getIntent();
// Developer can choose to assert different relevant properties of the returned intent, such as the action, activity, package, or scheme
assertEquals("settings", intent.getStringExtra("featureParam"));
assertEquals("actions.intent.OPEN_APP_FEATURE", intent.getAction());
assertEquals("com.google.android.youtube/.MainActivity", intent.getComponent().flattenToShortString());
assertEquals("com.google.myapp", intent.getPackage());
// Developers can choose to use returned Android Intent to launch and assess the activity. Below are examples for how it will look like for Robolectric and Espresso tests.
// Please note that the below part is just a possible example of how Android tests are validating Activity functionality correctness for given Android Intent.
// Robolectric example:
MainActivity activity = Robolectric.buildActivity(MainActivity.class,intentResult.intent).create().resume().get();
TextView title: TextView = activity.findViewById(R.id.startActivityTitle)
assertEquals(title?.getText()?.toString(), "Launching…")
}
Activity