Skip to content

Commit

Permalink
Android UI Kit v2.1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Feb 22, 2021
1 parent 8f8ddea commit fa7f171
Show file tree
Hide file tree
Showing 43 changed files with 1,050 additions and 120 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Learn more about how to integrate [UI Kit](https://github.com/cometchat-pro/andr

## Troubleshooting

- To read the full dcoumentation on UI Kit integration visit our [Documentation](https://prodocs.cometchat.com/docs/android-ui-kit) .
- To read the full documentation on UI Kit integration visit our [Documentation](https://prodocs.cometchat.com/docs/android-ui-kit) .

- Facing any issues while integrating or installing the UI Kit please <a href="https://app.cometchat.io/"> connect with us via real time support present in CometChat Dashboard.</a>.

Expand Down
14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ dependencies {

testImplementation 'junit:junit:4.12'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
// Core library
androidTestImplementation 'androidx.test:core:1.3.0'
// Espresso dependencies

androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
// Assertions

androidTestImplementation 'androidx.test.ext:junit:1.1.1'

androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation project(path: ':uikit')
Expand All @@ -60,5 +72,5 @@ dependencies {
implementation 'com.facebook.shimmer:shimmer:0.4.0'

//
implementation 'com.cometchat:pro-android-chat-sdk:2.1.7-beta3'
implementation 'com.cometchat:pro-android-chat-sdk:2.2.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.cometchat.pro.androiduikit;

import com.cometchat.pro.androiduikit.app.ComponentActivityTest;
import com.cometchat.pro.androiduikit.app.MainActivityTest;
import com.cometchat.pro.androiduikit.app.SelectActivityTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses(
{
MainActivityTest.class,
CreateUserActivity.class,
SelectActivityTest.class,
ComponentActivityTest.class
})

public class AppTestSuite {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
package com.cometchat.pro.androiduikit.app;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.NoMatchingViewException;
import androidx.test.espresso.PerformException;
import androidx.test.espresso.ViewAssertion;
import androidx.test.espresso.ViewInteraction;
import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.assertion.ViewAssertions;
import androidx.test.espresso.contrib.RecyclerViewActions;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.Until;

import com.cometchat.pro.androiduikit.ComponentListActivity;
import com.cometchat.pro.androiduikit.R;
import com.cometchat.pro.androiduikit.utils.RecyclerViewAssertion;

import org.junit.Assert;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runners.MethodSorters;

import static androidx.test.espresso.action.ViewActions.clearText;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
import static androidx.test.espresso.action.ViewActions.pressBack;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withParent;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static org.hamcrest.core.AllOf.allOf;


@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ComponentActivityTest {


private static final String BASIC_SAMPLE_PACKAGE
= "com.cometchat.pro.androiduikit";

private static final int LAUNCH_TIMEOUT = 5000;

private UiDevice mDevice;

@Rule
public ActivityTestRule<ComponentListActivity> activityRule = new ActivityTestRule<>(ComponentListActivity.class, true, false);

@Before
public void setup() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
Context context = getInstrumentation().getContext();
Intent intent = context.getPackageManager()
.getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

// Clear out any previous instances
context.startActivity(intent);
mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
Espresso.onView(ViewMatchers.withId(R.id.componentLaunch)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.componentLaunch)).perform(ViewActions.click());
}

@Test
public void A_checkAvatar() {

//Check Components
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_avatar)).perform(ViewActions.scrollTo());
Espresso.onView(withId(R.id.cometchat_avatar)).perform(click());
Espresso.onView(withId(R.id.borderWidth)).perform(ViewActions.typeText("5"))
.perform(closeSoftKeyboard());
Thread.sleep(2000);
Espresso.onView(withId(R.id.borderWidth)).perform(pressBack());
mDevice.pressBack();
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
public void B_checkBadgeCount() {
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_badge_count)).perform(ViewActions.scrollTo());
Espresso.onView(withId(R.id.cometchat_badge_count)).perform(click());
Espresso.onView(withId(R.id.badgeCount_edt)).perform(clearText())
.perform(ViewActions.typeText("9999"));
Thread.sleep(2000);
Espresso.onView(withId(R.id.countSize)).perform(clearText())
.perform(ViewActions.typeText("12"))
.perform(closeSoftKeyboard());
Thread.sleep(2000);
Espresso.onView(withId(R.id.countSize)).perform(pressBack());
mDevice.pressBack();
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
public void C_checkStatusIndicator() {
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_status_indicator)).perform(ViewActions.scrollTo());
Espresso.onView(withId(R.id.cometchat_status_indicator)).perform(click());
Espresso.onView(withId(R.id.offline)).perform(click());
Espresso.onView(withId(R.id.offline)).check(matches(ViewMatchers.isChecked()));

Espresso.onView(withId(R.id.online)).perform(click());
Espresso.onView(withId(R.id.online)).check(matches(ViewMatchers.isChecked()))
.perform(closeSoftKeyboard()).perform(pressBack());
mDevice.pressBack();
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
public void J_checkCallList() {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_callList)).perform(ViewActions.scrollTo());
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_callList)).check(matches(isDisplayed()));
Espresso.onView(ViewMatchers.withId(R.id.cometchat_callList)).perform(click());
} catch (AssertionError e) {
Log.e("D_checkCallList: ",e.getMessage() );
} catch (NoMatchingViewException e) {
Log.e("D_checkCallList: ",e.getMessage() );
}
try {

Espresso.onView(ViewMatchers.withId(R.id.callList_rv))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (PerformException e) {
Assert.assertTrue("View Not loaded",true);
} catch (Exception e) {
Assert.fail();
}
}

@Test
public void K_checkCallList_2Sec() {
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_callList)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_callList)).perform(click());
Thread.sleep(2000);
Espresso.onView(ViewMatchers.withId(R.id.callList_rv))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (InterruptedException e) {
e.printStackTrace();
}
}

@Test
public void D_checkUserList() {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_user_view)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_user_view)).perform(click());
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchatUserList))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (PerformException e) {
Assert.assertTrue("View not loaded",true);
} catch (Exception e) {
Assert.fail();
}
}

@Test
public void E_checkUserList_2Sec() {
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_user_view)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_user_view)).perform(ViewActions.click());
Thread.sleep(2000);
Espresso.onView(ViewMatchers.withId(R.id.cometchatUserList))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (InterruptedException e) {
e.printStackTrace();
}
}

@Test
public void F_checkGroupList() {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_group_view)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_group_view)).perform(ViewActions.click());
Espresso.onView(ViewMatchers.withId(R.id.cometchatGroupList))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
}

@Test
public void G_checkGroupList_2Sec() {
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_group_view)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_group_view)).perform(ViewActions.click());
Thread.sleep(2000);
Espresso.onView(ViewMatchers.withId(R.id.cometchatGroupList))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (InterruptedException e) {
e.printStackTrace();
}
}

@Test
public void H_checkConversationList() {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_conversation_view)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_conversation_view)).perform(ViewActions.click());
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchatConversationList))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (PerformException e) {
Assert.assertTrue("View not loaded",true);
} catch (Exception e) {
Assert.fail();
}
}

@Test
public void I_checkConversationList_2Sec() {
try {
Espresso.onView(ViewMatchers.withId(R.id.cometchat_conversation_view)).perform(ViewActions.scrollTo());
Espresso.onView(ViewMatchers.withId(R.id.cometchat_conversation_view)).perform(ViewActions.click());
Thread.sleep(2000);
Espresso.onView(ViewMatchers.withId(R.id.cometchatConversationList))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
} catch (InterruptedException e) {
e.printStackTrace();
}
}

// RecyclerView callRv = activityRule.getActivity().findViewById(R.id.cometchat_callList);
// int itemCount = callRv.getAdapter().getItemCount();
// if (itemCount>0) {
// Espresso.onView(withId(R.id.cometchat_callList)).perform(click());
// }

}
Loading

0 comments on commit fa7f171

Please sign in to comment.