diff options
author | Erica Chang <echang@cyngn.com> | 2016-04-14 12:19:08 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-05-13 11:11:32 -0700 |
commit | d90403ff078159f161bdc0e12860e2615852322e (patch) | |
tree | b1892655891b4faa7d9a696fcace1e1536dadda8 /androidTest/src/com/android/contacts/androidtest/InCallMetricsSendTest.java | |
parent | a721e708019f773af31680d0a9a4d4343f1fa7ef (diff) | |
download | packages_apps_Contacts-d90403ff078159f161bdc0e12860e2615852322e.tar.gz packages_apps_Contacts-d90403ff078159f161bdc0e12860e2615852322e.tar.bz2 packages_apps_Contacts-d90403ff078159f161bdc0e12860e2615852322e.zip |
Contacts InCall metrics test
-added espresso & uiautomator for UI automation
-added test cases for metrics
-INAPP_NUDGE_CONTACTS_TAB_LOGIN
-DIRECTORY_SEARCH (from contacts tab)
-CONTACTS_MANUAL_MERGED
-CONTACTS_AUTO_MERGED
-INVITES_SENT
-DIRECTORY_SEARCH
-INAPP_NUDGE_CONTACTS_LOGIN
-INAPP_NUDGE_CONTACTS_INSTALL
Change-Id: I86e5827b19ed4f313d55902198d5f3ccb25b20e8
Diffstat (limited to 'androidTest/src/com/android/contacts/androidtest/InCallMetricsSendTest.java')
-rw-r--r-- | androidTest/src/com/android/contacts/androidtest/InCallMetricsSendTest.java | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/androidTest/src/com/android/contacts/androidtest/InCallMetricsSendTest.java b/androidTest/src/com/android/contacts/androidtest/InCallMetricsSendTest.java new file mode 100644 index 000000000..aea748cdf --- /dev/null +++ b/androidTest/src/com/android/contacts/androidtest/InCallMetricsSendTest.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2016 The CyanogenMod Project + * + * 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.android.contacts.androidtest; + +import android.content.ComponentName; +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.rules.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; +import android.test.suitebuilder.annotation.MediumTest; +import android.util.Log; + +import com.android.contacts.activities.PeopleActivity; +import com.android.contacts.incall.InCallMetricsDbHelper; +import com.android.contacts.incall.InCallMetricsHelper; +import com.android.phone.common.incall.CallMethodInfo; +import com.android.phone.common.incall.ContactsDataSubscription; +import com.android.phone.common.incall.utils.CallMethodFilters; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.HashMap; +import java.util.Set; + +@RunWith(AndroidJUnit4.class) +@MediumTest +public class InCallMetricsSendTest { + private static final String TAG = InCallMetricsSendTest.class.getSimpleName(); + + private Context mContext; + private CallMethodInfo mCm; + + @Rule + public ActivityTestRule<PeopleActivity> mActivityTestRule = new + ActivityTestRule<PeopleActivity>(PeopleActivity.class); + + @Before + public void setUp() { + mContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + // Query plugins + HashMap<ComponentName, CallMethodInfo> cmMap = + CallMethodFilters.getAllEnabledAndHiddenCallMethods( + ContactsDataSubscription.get(mContext)); + Assert.assertNotNull(cmMap); + Set<ComponentName> cmKeySet = cmMap.keySet(); + if (cmKeySet.size() == 0) { + Log.d(TAG, "No InCall plugin installed"); + return; + } + // test the first one + ComponentName cn = cmKeySet.iterator().next(); + mCm = cmMap.get(cn); + Assert.assertNotNull(mCm); + } + + @Test + public void sendTest() { + populateMetricsInDb(); + InCallMetricsTestUtils.waitFor(500); + InCallMetricsHelper.prepareAndSend(mContext); + } + + private void populateMetricsInDb() { + // Category: USER_ACTIONS + // CONTACTS_MANUAL_MERGED + InCallMetricsDbHelper.getInstance(mContext).incrementUserActionsParam( + mCm.mComponent.flattenToString(), + "", + InCallMetricsHelper.Events.CONTACTS_MANUAL_MERGED.value(), + InCallMetricsHelper.Categories.USER_ACTIONS.value(), + InCallMetricsHelper.Parameters.COUNT.toCol()); + // CONTACTS_AUTO_MERGED + InCallMetricsDbHelper.getInstance(mContext).incrementUserActionsParam( + mCm.mComponent.flattenToString(), + "", + InCallMetricsHelper.Events.CONTACTS_AUTO_MERGED.value(), + InCallMetricsHelper.Categories.USER_ACTIONS.value(), + InCallMetricsHelper.Parameters.COUNT.toCol()); + // INVITES_SENT + InCallMetricsHelper.increaseCount(mContext, InCallMetricsHelper.Events.INVITES_SENT, + mCm.mComponent.flattenToString()); + // DIRECTORY_SEARCH + InCallMetricsHelper.increaseCount(mContext, InCallMetricsHelper.Events.DIRECTORY_SEARCH, + mCm.mComponent.flattenToString()); + // Category: In App Nudges + // INAPP_NUDGE_CONTACTS_TAB_LOGIN + InCallMetricsHelper.setValue( + mContext, + mCm.mComponent, + InCallMetricsHelper.Categories.INAPP_NUDGES, + InCallMetricsHelper.Events.INAPP_NUDGE_CONTACTS_TAB_LOGIN, + InCallMetricsHelper.Parameters.EVENT_ACCEPTANCE, + InCallMetricsHelper.EVENT_ACCEPT, + InCallMetricsHelper.generateNudgeId(mCm.mLoginSubtitle)); + // INAPP_NUDGE_CONTACTS_LOGIN + InCallMetricsHelper.setValue( + mContext, + mCm.mComponent, + InCallMetricsHelper.Categories.INAPP_NUDGES, + InCallMetricsHelper.Events.INAPP_NUDGE_CONTACTS_LOGIN, + InCallMetricsHelper.Parameters.EVENT_ACCEPTANCE, + InCallMetricsHelper.EVENT_ACCEPT, + InCallMetricsHelper.generateNudgeId(mCm.mLoginNudgeSubtitle)); + // INAPP_NUDGE_CONTACTS_INSTALL + InCallMetricsHelper.setValue( + mContext, + mCm.mComponent, + InCallMetricsHelper.Categories.INAPP_NUDGES, + InCallMetricsHelper.Events.INAPP_NUDGE_CONTACTS_INSTALL, + InCallMetricsHelper.Parameters.EVENT_ACCEPTANCE, + InCallMetricsHelper.EVENT_DISMISS, + InCallMetricsHelper.generateNudgeId(mCm.mInstallNudgeSubtitle)); + } +} |