package com.huawei.wisesecurity.keyindexsample;
import com.huawei.wisesecurity.keyindexsample.activity.MainActivity;
import com.huawei.wisesecurity.keyindexsample.utils.TestTools;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.pressBack;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.replaceText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
/**
* 功能描述 keyindex自动化脚本
*
* @author dwx5322232
* @since 2020/12/23
*/
@RunWith(AndroidJUnit4.class)
public class unwrapGroupKey_forMeetingTest {
@Rule
public ActivityTestRule<MainActivity> mActivityTestRule =
new ActivityTestRule<>(MainActivity.class);
@Before
public void throughRegisterPage() throws InterruptedException {
onView(withId(R.id.btn_main_go2register_pub_key))
.perform(click());
onView(withId(R.id.btn_sign_in))
.perform(click());
Thread.sleep(1000);
onView(withId(R.id.btn_register_pubkey_initkeyindexsdk))
.perform(click());
onView(withId(R.id.btn_register_pubkey_register))
.perform(click());
Thread.sleep(500);
pressBack();
}
/**
* 调用会议的unwrapGroupKey接口, 解密groupKey成功
*/
@Test
public void unwrapGroupKey_forMeetingGroupKey() throws Exception {
onView(withId(R.id.btn_main_go2meeting))
.perform(click());
onView(withId(R.id.btn_meeting_gen_keypair))
.perform(click());
Thread.sleep(500);
key1 = TestTools.getText(withId(R.id.et_meeting_my_key_public));
onView(withId(R.id.btn_meeting_gen_keypair))
.perform(click());
Thread.sleep(500);
key2= TestTools.getText(withId(R.id.et_meeting_my_key_public));
onView(withId(R.id.et_meeting_peer_key_public))
.perform(replaceText(key1));
onView(withId(R.id.btn_meeting_gen_group_key))
.perform(click());
key3=TestTools.getText(withId(R.id.et_meeting_group_key_plain_text));
Thread.sleep(500);
onView(withId(R.id.btn_meeting_wrap_group_key))
.perform(click());
onView(withId(R.id.et_meeting_group_key_plain_text))
.perform(replaceText(""));
onView(withId(R.id.btn_meeting_unwrap_group_key))
.perform(click());
onView(withId(R.id.et_meeting_group_key_plain_text)).check(matches(withText(key3)));
}
}