From 9cb66eb2e8b5ac58cd6473f46d9ac4d9a87fc829 Mon Sep 17 00:00:00 2001 From: Eric Douglas Nyakam Chiadjeu Date: Mon, 21 Oct 2019 15:09:53 +0200 Subject: [PATCH] OT-466 Clean up block_unblock tests --- .gitignore | 1 - test_driver/block_unblock_test.dart | 49 +++--- ...chatList_test.dart => chat_list_test.dart} | 93 ++++++----- test_driver/contact_list_test.dart | 74 ++++----- test_driver/group_test.dart | 116 ++++++------- test_driver/login_test.dart | 102 ++++++------ test_driver/messages_actions_test.dart | 152 ++++++++++++++++++ test_driver/navigation_test.dart | 43 ++--- test_driver/profile_test.dart | 32 ++-- test_driver/setup/global_consts.dart | 8 +- test_driver/setup/helper_methods.dart | 146 +++++++++++------ test_driver/setup/main_test_setup.dart | 105 +++++++----- 12 files changed, 583 insertions(+), 338 deletions(-) rename test_driver/{chatList_test.dart => chat_list_test.dart} (69%) create mode 100644 test_driver/messages_actions_test.dart diff --git a/.gitignore b/.gitignore index 4d4720ff..e2c6feb8 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,3 @@ screenshots/ !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -/android/key.properties diff --git a/test_driver/block_unblock_test.dart b/test_driver/block_unblock_test.dart index 87b4efa9..5decccca 100644 --- a/test_driver/block_unblock_test.dart +++ b/test_driver/block_unblock_test.dart @@ -41,11 +41,13 @@ */ import 'package:flutter_driver/flutter_driver.dart'; +import 'package:ox_coi/src/utils/keyMapping.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'package:test/test.dart'; -import 'package:test_api/src/backend/invoker.dart'; void main() { group('Test block / unblock functionality', () { @@ -57,17 +59,19 @@ void main() { test('Test block / unblock functionality.', () async { // Check real authentication and get chat. await getAuthentication( - setup.driver, - signInFinder, - coiDebugProviderFinder, - providerEmailFinder, - realEmail, - providerPasswordFinder, - realPassword); + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); Invoker.current.heartbeat(); await setup.driver.waitFor(chatWelcomeFinder); Invoker.current.heartbeat(); + // Get contacts and add new contacts. await setup.driver.tap(contactsFinder); await setup.driver.tap(cancelFinder); @@ -75,16 +79,25 @@ void main() { // Add two new contacts in the contact list. await addNewContact( - setup.driver, - personAddFinder, - keyContactChangeNameFinder, - newTestName01, - keyContactChangeEmailFinder, - newTestContact01, - keyContactChangeCheckFinder); + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newTestName01, + keyContactChangeEmailFinder, + newTestContact01, + keyContactChangeCheckFinder, + ); + + // Block one contact and check the blocking, + await blockOneContactFromContacts(setup.driver, newTestName01); + await setup.driver.waitForAbsent(find.text(newTestName01)); + await setup.driver.tap(find.byValueKey(keyContactListBlockIconButton)); + await setup.driver.waitFor(find.text(newTestName01)); + await catchScreenshot(setup.driver, 'screenshots/blockedList.png'); - // Block one contact. - await blockOneContact(setup.driver, newTestName01); + // Unblock one contact and check the unblocking. + await unblockOneContactFromBlockedContacts(setup.driver, newTestName01); + await setup.driver.waitFor(find.text(newTestName01)); }); }); } diff --git a/test_driver/chatList_test.dart b/test_driver/chat_list_test.dart similarity index 69% rename from test_driver/chatList_test.dart rename to test_driver/chat_list_test.dart index ae12b5f6..c68b607c 100644 --- a/test_driver/chatList_test.dart +++ b/test_driver/chat_list_test.dart @@ -43,11 +43,12 @@ // Imports the Flutter Driver API. import 'package:flutter_driver/flutter_driver.dart'; import 'package:ox_coi/src/utils/keyMapping.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'package:test/test.dart'; -import 'package:test_api/src/backend/invoker.dart'; void main() { group('Create chat list integration tests.', () { @@ -57,72 +58,88 @@ void main() { test('Test Create chat list integration tests.', () async { await getAuthentication( - setup.driver, - signInFinder, - coiDebugProviderFinder, - providerEmailFinder, - realEmail, - providerPasswordFinder, - realPassword); + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); // Create first Me contact. - await createNewChat(setup.driver, createChatFinder, realEmail, meContact, - newContact, name, enterContactName, emptyChat); + await createNewChat( + setup.driver, + createChatFinder, + realEmail, + meContact, + newContact, + name, + enterContactName, + emptyChat, + ); // Create second contact. - await createNewChat(setup.driver, createChatFinder, newTestContact02, - newTestName02, newContact, name, enterContactName, emptyChat); + await createNewChat( + setup.driver, + createChatFinder, + newTestContact02, + newTestName02, + newContact, + name, + enterContactName, + emptyChat, + ); // create third contact - await createNewChat(setup.driver, createChatFinder, newTestContact01, - newTestName01, newContact, name, enterContactName, emptyChat); + await createNewChat( + setup.driver, + createChatFinder, + newTestContact01, + newTestName01, + newContact, + name, + enterContactName, + emptyChat, + ); // Type something and get it. - await chatTest(setup.driver, newTestName01, - typeSomethingComposePlaceholderFinder, helloWord); + await chatTest(setup.driver, newTestName01, typeSomethingComposePlaceholderFinder, helloWorld); await callTest(setup.driver); + await setup.driver.tap(pageBack); // Search contact. await chatSearch( - setup.driver, - newTestName01, - searchString, - find.byValueKey(keyChatListSearchIconButton), - keySearchReturnIconButton); + setup.driver, + newTestName01, + searchString, + find.byValueKey(keyChatListSearchIconButton), + keySearchReturnIconButton, + ); }); }); } -Future createNewChat( - FlutterDriver driver, - SerializableFinder finderCreateChat, - String chatEmail, - String chatName, - String newContact, - String name, - String enterContactName, - String emptyChat) async { +Future createNewChat(FlutterDriver driver, SerializableFinder finderCreateChat, String chatEmail, String chatName, String newContact, String name, + String enterContactName, String emptyChat) async { final finderMe = find.text(meContact); final finderNewContact = find.text(newContact); Invoker.current.heartbeat(); await driver.tap(finderCreateChat); if (chatName == meContact) { await driver.tap(finderMe); - await driver.tap(find.pageBack()); + await driver.tap(pageBack); await driver.waitFor(finderMe); } else { Invoker.current.heartbeat(); await driver.tap(finderNewContact); await driver.waitFor(find.text(name)); await driver.waitFor(find.text(emailAddress)); - await driver - .tap(find.byValueKey(keyContactChangeNameValidatableTextFormField)); + await driver.tap(find.byValueKey(keyContactChangeNameValidatableTextFormField)); await driver.waitFor(find.text(enterContactName)); await driver.enterText(chatName); - await driver - .tap(find.byValueKey(keyContactChangeEmailValidatableTextFormField)); + await driver.tap(find.byValueKey(keyContactChangeEmailValidatableTextFormField)); await driver.waitFor(find.text(emailAddress)); await driver.enterText(chatEmail); await driver.tap(find.byValueKey(keyContactChangeCheckIconButton)); await driver.waitFor(find.text(emptyChat)); - await driver.tap(find.pageBack()); + await driver.tap(pageBack); await catchScreenshot(driver, 'screenshots/chatListeAfterCreated.png'); } } - diff --git a/test_driver/contact_list_test.dart b/test_driver/contact_list_test.dart index 506b64f3..8ab2e6cf 100644 --- a/test_driver/contact_list_test.dart +++ b/test_driver/contact_list_test.dart @@ -43,18 +43,18 @@ // Imports the Flutter Driver API. import 'package:flutter_driver/flutter_driver.dart'; import 'package:ox_coi/src/utils/keyMapping.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'package:test/test.dart'; -import 'package:test_api/src/backend/invoker.dart'; void main() { group( 'Create contact list integration tests: After login, Me contact is checked first, ' 'then two contacts are created. The contacts made can then be found in the contact list.' - 'After that one of the contacts will be delete from the contact list', - () { + 'After that one of the contacts will be delete from the contact list', () { // Define the driver. FlutterDriver driver; Setup setup = new Setup(driver); @@ -63,13 +63,14 @@ void main() { test('Test create profile integration tests.', () async { // Check real authentication and get chat. await getAuthentication( - setup.driver, - signInFinder, - coiDebugProviderFinder, - providerEmailFinder, - realEmail, - providerPasswordFinder, - realPassword); + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); Invoker.current.heartbeat(); await setup.driver.waitFor(chatWelcomeFinder); @@ -81,31 +82,28 @@ void main() { // Add two new contacts in the contact list. await addNewContact( - setup.driver, - personAddFinder, - keyContactChangeNameFinder, - newTestName01, - keyContactChangeEmailFinder, - newTestContact01, - keyContactChangeCheckFinder); + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newTestName01, + keyContactChangeEmailFinder, + newTestContact01, + keyContactChangeCheckFinder, + ); await addNewContact( - setup.driver, - personAddFinder, - keyContactChangeNameFinder, - newTestName02, - keyContactChangeEmailFinder, - newTestContact02, - keyContactChangeCheckFinder); + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newTestName02, + keyContactChangeEmailFinder, + newTestContact02, + keyContactChangeCheckFinder, + ); // Manage new contact await manageContact( - setup.driver, - newTestName01, - keyContactChangeNameFinder, - newMe, - keyContactChangeCheckFinder, - keyContactDetailEditContactProfileActionIcon); + setup.driver, newTestName01, keyContactChangeNameFinder, newMe, keyContactChangeCheckFinder, keyContactDetailEditContactProfileActionIcon); await catchScreenshot(setup.driver, 'screenshots/persone_add02.png'); print('\nContacts'); // Delete one contact @@ -116,20 +114,14 @@ void main() { }); } -Future manageContact( - FlutterDriver driver, - String newTestName, - SerializableFinder keyContactChangeNameFinder, - String newMe, - SerializableFinder keyContactChangeCheckFinder, - String keyContactDetailEditContactProfileActionIcon) async { +Future manageContact(FlutterDriver driver, String newTestName, SerializableFinder keyContactChangeNameFinder, String newMe, + SerializableFinder keyContactChangeCheckFinder, String keyContactDetailEditContactProfileActionIcon) async { await driver.tap(find.text(newTestName)); Invoker.current.heartbeat(); await driver.waitFor(find.text(newTestName)); - await driver - .tap(find.byValueKey(keyContactDetailEditContactProfileActionIcon)); + await driver.tap(find.byValueKey(keyContactDetailEditContactProfileActionIcon)); await driver.tap(keyContactChangeNameFinder); await driver.enterText(newMe); await driver.tap(keyContactChangeCheckFinder); - await driver.tap(find.pageBack()); + await driver.tap(pageBack); } diff --git a/test_driver/group_test.dart b/test_driver/group_test.dart index cad4800b..69006cd7 100644 --- a/test_driver/group_test.dart +++ b/test_driver/group_test.dart @@ -41,12 +41,13 @@ */ import 'package:flutter_driver/flutter_driver.dart'; +import 'package:ox_coi/src/utils/keyMapping.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'package:test/test.dart'; -import 'package:test_api/src/backend/invoker.dart'; -import 'package:ox_coi/src/utils/keyMapping.dart'; void main() { group('Test group chat functionality.', () { @@ -63,47 +64,51 @@ void main() { final popupItemRemove = "Remove from group"; final popupItemSendMessage = "Send message"; final searchNew = "new"; - final groupParticipants = "4 participants"; + final groupParticipants = "3 participants"; test('Test group chat functionality.', () async { // Check real authentication and get chat. await getAuthentication( - setup.driver, - signInFinder, - coiDebugProviderFinder, - providerEmailFinder, - realEmail, - providerPasswordFinder, - realPassword); + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); Invoker.current.heartbeat(); await navigateTo(setup.driver, contacts); await setup.driver.tap(cancelFinder); // Add tree new contacts in the contact list. await addNewContact( - setup.driver, - personAddFinder, - keyContactChangeNameFinder, - newTestName01, - keyContactChangeEmailFinder, - newTestContact01, - keyContactChangeCheckFinder); + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newTestName01, + keyContactChangeEmailFinder, + newTestContact01, + keyContactChangeCheckFinder, + ); await addNewContact( - setup.driver, - personAddFinder, - keyContactChangeNameFinder, - newTestName02, - keyContactChangeEmailFinder, - newTestContact02, - keyContactChangeCheckFinder); + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newTestName02, + keyContactChangeEmailFinder, + newTestContact02, + keyContactChangeCheckFinder, + ); await addNewContact( - setup.driver, - personAddFinder, - keyContactChangeNameFinder, - newMe, - keyContactChangeEmailFinder, - newTestContact04, - keyContactChangeCheckFinder); + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newMe, + keyContactChangeEmailFinder, + newTestContact04, + keyContactChangeCheckFinder, + ); await catchScreenshot(setup.driver, 'screenshots/group1.png'); navigateTo(setup.driver, chat); @@ -114,18 +119,15 @@ void main() { await setup.driver.tap(find.text(newTestName01)); await setup.driver.tap(find.text(newTestName02)); // Validate an create group. - await setup.driver - .tap(find.byValueKey(keyChatCreateGroupParticipantsSummitIconButton)); + await setup.driver.tap(find.byValueKey(keyChatCreateGroupParticipantsSummitIconButton)); // Check if the group has been really created, and add group's name. await setup.driver.waitFor(find.text(newTestName01)); await setup.driver.waitFor(find.text(newTestName02)); // Edit group's name. - await setup.driver - .tap(find.byValueKey(keyChatCreateGroupSettingsGroupNameField)); + await setup.driver.tap(find.byValueKey(keyChatCreateGroupSettingsGroupNameField)); await setup.driver.enterText(testNameGroup); - await setup.driver - .tap(find.byValueKey(keyChatCreateGroupSettingCheckIconButton)); + await setup.driver.tap(find.byValueKey(keyChatCreateGroupSettingCheckIconButton)); await catchScreenshot(setup.driver, 'screenshots/group2.png'); // Type something and get it. @@ -135,40 +137,39 @@ void main() { // Change the group's name. await setup.driver.tap(find.byValueKey(keyChatProfileGroupEditIcon)); - await setup.driver - .tap(find.byValueKey(keyEditNameValidatableTextFormField)); + await setup.driver.tap(find.byValueKey(keyEditNameValidatableTextFormField)); await setup.driver.enterText(newNameTestGroup); await setup.driver.tap(find.byValueKey(keyEditNameCheckIcon)); await setup.driver.waitFor(find.text(newNameTestGroup)); - await setup.driver.tap(find.pageBack()); - await setup.driver.tap(find.pageBack()); - await chatTest(setup.driver, newNameTestGroup, - typeSomethingComposePlaceholderFinder, helloWord); - await setup.driver.tap(find.pageBack()); + await setup.driver.tap(pageBack); + await setup.driver.tap(pageBack); + await chatTest( + setup.driver, + newNameTestGroup, + typeSomethingComposePlaceholderFinder, + helloWorld, + ); + await setup.driver.tap(pageBack); await catchScreenshot(setup.driver, 'screenshots/NewNameTestGroup2.png'); // Add new Participants in the group and test. await setup.driver.tap(find.text(newNameTestGroup)); await setup.driver.tap(find.byValueKey(keyChatNameText)); - await setup.driver - .tap(find.byValueKey(keyChatProfileGroupAddParticipant)); - await setup.driver - .tap(find.byValueKey(keyChatAddGroupParticipantsSearchIcon)); + await setup.driver.tap(find.byValueKey(keyChatProfileGroupAddParticipant)); + await setup.driver.tap(find.byValueKey(keyChatAddGroupParticipantsSearchIcon)); await catchScreenshot(setup.driver, 'screenshots/newContactAdded.png'); await setup.driver.enterText(searchNew); await setup.driver.tap(find.text(newMe)); await setup.driver.tap(find.byValueKey(keySearchReturnIconButton)); - await setup.driver - .tap(find.byValueKey(keyChatAddGroupParticipantsCheckIcon)); + await setup.driver.tap(find.byValueKey(keyChatAddGroupParticipantsCheckIcon)); await catchScreenshot(setup.driver, 'screenshots/newContactAdded2.png'); - await setup.driver.waitFor(find.text(newMe)); await setup.driver.waitFor(find.text(groupParticipants)); // Check popupMenu. // Test info menu await setup.driver.tap(find.byValueKey(keyMoreButton11)); await setup.driver.tap(find.text(popupItemInfo)); - await setup.driver.tap(find.pageBack()); + await setup.driver.tap(pageBack); // Test remove menu. await setup.driver.tap(find.byValueKey(keyMoreButton11)); await setup.driver.tap(find.text(popupItemRemove)); @@ -176,17 +177,16 @@ void main() { // Test send menu. await setup.driver.tap(find.byValueKey(keyMoreButton10)); await setup.driver.tap(find.text(popupItemSendMessage)); - await writeChatFromChat(setup.driver, helloWord); - await setup.driver.tap(find.pageBack()); + await writeChatFromChat(setup.driver, helloWorld); + await setup.driver.tap(pageBack); // Leave group. await setup.driver.tap(find.text(newNameTestGroup)); await setup.driver.tap(find.byValueKey(keyChatNameText)); await setup.driver.tap(find.byValueKey(keyChatProfileGroupDelete)); - await setup.driver - .tap(find.byValueKey(keyDialogBuilderPositiveFlatButton)); + await setup.driver.tap(find.byValueKey(keyDialogBuilderPositiveFlatButton)); await catchScreenshot(setup.driver, 'screenshots/leave.png'); await setup.driver.waitForAbsent(find.text(newNameTestGroup)); }); }); -} \ No newline at end of file +} diff --git a/test_driver/login_test.dart b/test_driver/login_test.dart index a6159b40..eda9aa10 100644 --- a/test_driver/login_test.dart +++ b/test_driver/login_test.dart @@ -45,11 +45,12 @@ import 'package:flutter_driver/flutter_driver.dart'; import 'package:ox_coi/src/l10n/l.dart'; import 'package:ox_coi/src/utils/keyMapping.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'package:test/test.dart'; -import 'package:test_api/src/backend/invoker.dart'; void main() { group('Ox coi test:', () { @@ -66,7 +67,7 @@ void main() { final outlook = find.text('Outlook'); final yahoo = find.text('Yahoo'); final mailbox = find.text('Mailbox.org'); - final loginProviderSignInText = 'Sign in with Coi debug'; + final loginProviderSignInText = 'Sign in with Debug (mobile-qa)'; // SerializableFinder for Coi Debug dialog Windows. final signInCoiDebug = find.text(loginProviderSignInText); @@ -79,21 +80,20 @@ void main() { test('Test login.', () async { // Test Ox.coi welcome screen and tap on SIGN In to get the provider list, and test if all provider are contained in the list. await checkOxCoiWelcomeAndProviderList( - setup.driver, - welcomeMessage, - welcomeDescription, - signInCaps, - register, - outlook, - yahoo, - signIn, - find.text(coiDebug), - other, - mailbox); - await setup.driver - .scroll(find.text(mailCom), 0, -600, Duration(milliseconds: 500)); - await selectAndTapProvider( - setup.driver, find.text(coiDebug), signInCoiDebug, email, password); + setup.driver, + welcomeMessage, + welcomeDescription, + signInCaps, + register, + outlook, + yahoo, + signIn, + find.text(coiDebug), + other, + mailbox, + ); + await setup.driver.scroll(find.text(mailCom), 0, -600, Duration(milliseconds: 500)); + await selectAndTapProvider(setup.driver, find.text(coiDebug), signInCoiDebug, email, password); await catchScreenshot(setup.driver, 'screenshots/CoiDebug.png'); // Try to sign in without email an password. @@ -103,26 +103,21 @@ void main() { // Try fake authentication. print('SIGN IN without email and password.'); - await getAuthentication( - setup.driver, email, ' ', password, ' ', signInCaps); + await getAuthentication(setup.driver, email, ' ', password, ' ', signInCaps); await setup.driver.waitFor(errorMessage); - await catchScreenshot( - setup.driver, 'screenshots/withoutEmailandPassword.png'); + await catchScreenshot(setup.driver, 'screenshots/withoutEmailandPassword.png'); print('SIGN IN without email.'); - await getAuthentication( - setup.driver, email, ' ', password, fakePassword, signInCaps); + await getAuthentication(setup.driver, email, ' ', password, fakePassword, signInCaps); await setup.driver.waitFor(errorMessage); await catchScreenshot(setup.driver, 'screenshots/withoutEmail.png'); print('SIGN IN without password.'); - await getAuthentication( - setup.driver, email, fakeEmail, password, ' ', signInCaps); + await getAuthentication(setup.driver, email, fakeEmail, password, ' ', signInCaps); await setup.driver.waitFor(errorMessage); await catchScreenshot(setup.driver, 'screenshots/withoutPassword.png'); // Check real authentication and get chat. print('Real authentication.'); - await getAuthentication( - setup.driver, email, realEmail, password, realPassword, signInCaps); + await getAuthentication(setup.driver, email, realEmail, password, realPassword, signInCaps); await catchScreenshot(setup.driver, 'screenshots/entered.png'); Invoker.current.heartbeat(); print('SIGN IN ist done. Wait for chat.'); @@ -135,19 +130,20 @@ void main() { } Future checkOxCoiWelcomeAndProviderList( - FlutterDriver driver, - SerializableFinder welcomeMessage, - SerializableFinder welcomeDescription, - SerializableFinder signInCaps, - SerializableFinder register, - SerializableFinder outlook, - SerializableFinder yahoo, - SerializableFinder signIn, - SerializableFinder coiDebug, - SerializableFinder other, - SerializableFinder mailbox) async { - await driver.waitFor(welcomeMessage); - await driver.waitFor(welcomeDescription); + FlutterDriver driver, + SerializableFinder welcomeMessage, + SerializableFinder welcomeDescription, + SerializableFinder signInCaps, + SerializableFinder register, + SerializableFinder outlook, + SerializableFinder yahoo, + SerializableFinder signIn, + SerializableFinder coiDebug, + SerializableFinder other, + SerializableFinder mailbox, +) async { + //await driver.waitFor(welcomeMessage); + //await driver.waitFor(welcomeDescription); await driver.waitFor(signInCaps); await driver.waitFor(register); await driver.tap(signInCaps); @@ -162,11 +158,12 @@ Future checkOxCoiWelcomeAndProviderList( } Future selectAndTapProvider( - FlutterDriver driver, - SerializableFinder coiDebug, - SerializableFinder signInCoiDebug, - SerializableFinder email, - SerializableFinder password) async { + FlutterDriver driver, + SerializableFinder coiDebug, + SerializableFinder signInCoiDebug, + SerializableFinder email, + SerializableFinder password, +) async { await driver.tap(coiDebug); await driver.waitFor(signInCoiDebug); await driver.waitFor(email); @@ -174,12 +171,13 @@ Future selectAndTapProvider( } Future getAuthentication( - FlutterDriver driver, - SerializableFinder email, - String fakeEmail, - SerializableFinder password, - String realPassword, - SerializableFinder signInCaps) async { + FlutterDriver driver, + SerializableFinder email, + String fakeEmail, + SerializableFinder password, + String realPassword, + SerializableFinder signInCaps, +) async { await driver.tap(email); await driver.enterText(fakeEmail); await driver.waitFor(email); diff --git a/test_driver/messages_actions_test.dart b/test_driver/messages_actions_test.dart new file mode 100644 index 00000000..aeb2772e --- /dev/null +++ b/test_driver/messages_actions_test.dart @@ -0,0 +1,152 @@ +/* + * + * * OPEN-XCHANGE legal information + * * + * * All intellectual property rights in the Software are protected by + * * international copyright laws. + * * + * * + * * In some countries OX, OX Open-Xchange and open xchange + * * as well as the corresponding Logos OX Open-Xchange and OX are registered + * * trademarks of the OX Software GmbH group of companies. + * * The use of the Logos is not covered by the Mozilla Public License 2.0 (MPL 2.0). + * * Instead, you are allowed to use these Logos according to the terms and + * * conditions of the Creative Commons License, Version 2.5, Attribution, + * * Non-commercial, ShareAlike, and the interpretation of the term + * * Non-commercial applicable to the aforementioned license is published + * * on the web site https://www.open-xchange.com/terms-and-conditions/. + * * + * * Please make sure that third-party modules and libraries are used + * * according to their respective licenses. + * * + * * Any modifications to this package must retain all copyright notices + * * of the original copyright holder(s) for the original code used. + * * + * * After any such modifications, the original and derivative code shall remain + * * under the copyright of the copyright holder(s) and/or original author(s) as stated here: + * * https://www.open-xchange.com/legal/. The contributing author shall be + * * given Attribution for the derivative code and a license granting use. + * * + * * Copyright (C) 2016-2020 OX Software GmbH + * * Mail: info@open-xchange.com + * * + * * + * * This Source Code Form is subject to the terms of the Mozilla Public + * * License, v. 2.0. If a copy of the MPL was not distributed with this + * * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * * + * * This program is distributed in the hope that it will be useful, but + * * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * * or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License 2.0 + * * for more details. + * + * + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License 2.0 + * for more details. + */ + +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + +import 'setup/global_consts.dart'; +import 'setup/helper_methods.dart'; +import 'setup/main_test_setup.dart'; + +void main() { + group('Test block / unblock functionality', () { + // Define the driver. + FlutterDriver driver; + Setup setup = new Setup(driver); + setup.main(timeout); + + final openChat = 'Open chat'; + final flagUnFlag = 'Flag/Unflag'; + final forward = 'Forward'; + final textToDelete = 'Text to dellete'; + final paste = 'PASTE'; + final copy = 'Copy'; + + final meContactFinder = find.text(meContact); + final textToDeleteFinder = find.text(textToDelete); + + test('Test block / unblock functionality.', () async { + // Check real authentication and get chat. + await getAuthentication( + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); + + Invoker.current.heartbeat(); + await setup.driver.waitFor(chatWelcomeFinder); + Invoker.current.heartbeat(); + + // Get contacts and add new contacts. + await setup.driver.tap(contactsFinder); + await setup.driver.tap(cancelFinder); + await setup.driver.waitFor(meContactFinder); + + // Add two new contacts in the contact list. + await addNewContact( + setup.driver, + personAddFinder, + keyContactChangeNameFinder, + newTestName01, + keyContactChangeEmailFinder, + newTestContact01, + keyContactChangeCheckFinder, + ); + + // Create chat and write something. + await setup.driver.tap(meContactFinder); + await setup.driver.tap(find.text(openChat)); + await writeChatFromChat(setup.driver, helloWorld); + + // First test action: Flagged messages from meChat. + await flaggedMessage(setup.driver, flagUnFlag, helloWorldFinder); + + await setup.driver.tap(pageBack); + await navigateTo(setup.driver, chat); + + // Second test action: UnFlagged messages. + await unFlaggedMessage(setup.driver, flagUnFlag, helloWorldFinder); + await setup.driver.waitForAbsent(helloWorldFinder); + + // Return to chatList. + await setup.driver.tap(pageBack); + await setup.driver.tap(meContactFinder); + + // Third test action: Forward message. + await forwardMessageTo(setup.driver, newTestName01, forward); + await setup.driver.waitFor(helloWorldFinder); + + // Return to chatList. + await setup.driver.tap(pageBack); + await setup.driver.tap(meContactFinder); + + // Forth test action: Copy message from meContact and it paste in meContact. + await copyAndPasteMessage(setup.driver, copy, paste); + + // Enter new text to delete. + await writeTextInChat(setup.driver, textToDelete); + await setup.driver.waitFor(textToDeleteFinder); + await catchScreenshot(setup.driver, 'screenshots/addTextToDelete.png'); + + // Fifth test action: Delete message. + await deleteMessage(textToDeleteFinder, setup.driver); + await setup.driver.waitForAbsent(textToDeleteFinder); + }); + }); +} diff --git a/test_driver/navigation_test.dart b/test_driver/navigation_test.dart index b87d0837..4cc4da11 100644 --- a/test_driver/navigation_test.dart +++ b/test_driver/navigation_test.dart @@ -47,9 +47,10 @@ import 'package:ox_coi/src/l10n/l.dart'; import 'package:ox_coi/src/utils/keyMapping.dart'; import 'package:test/test.dart'; import 'package:test_api/src/backend/invoker.dart'; + +import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'setup/global_consts.dart'; void main() { group('Create chat list integration tests.', () { @@ -57,21 +58,20 @@ void main() { Setup setup = new Setup(driver); setup.main(timeout); - SerializableFinder searchReturnIconButton = - find.byValueKey(keySearchReturnIconButton); - SerializableFinder settingsUserSettingsUsernameLabelFinder = - find.byValueKey(keyUserSettingsUserSettingsUsernameLabel); + SerializableFinder searchReturnIconButton = find.byValueKey(keySearchReturnIconButton); + SerializableFinder settingsUserSettingsUsernameLabelFinder = find.byValueKey(keyUserSettingsUserSettingsUsernameLabel); test('Test Create chat list integration tests.', () async { // Check real authentication and get chat. await getAuthentication( - setup.driver, - signInFinder, - coiDebugProviderFinder, - providerEmailFinder, - realEmail, - providerPasswordFinder, - realPassword); + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); await setup.driver.tap(profileFinder); await setup.driver.tap(contactsFinder); @@ -93,13 +93,14 @@ void main() { // Test profile navigation. await checkProfile( - setup.driver, - profileFinder, - userProfileEditRaisedButtonFinder, - settingsUserSettingsUsernameLabelFinder, - userSettingsCheckIconButtonFinder, - contactsFinder, - cancelFinder); + setup.driver, + profileFinder, + userProfileEditRaisedButtonFinder, + settingsUserSettingsUsernameLabelFinder, + userSettingsCheckIconButtonFinder, + contactsFinder, + cancelFinder, + ); }); }); } @@ -134,13 +135,13 @@ Future checkChat( // Check flaggedButton. await driver.tap(find.byValueKey(keyChatListGetFlaggedActionIconButton)); - await driver.tap(find.pageBack()); + await driver.tap(pageBack); await catchScreenshot(driver, 'screenshots/afterFlaged.png'); Invoker.current.heartbeat(); await driver.tap(finderCreateChat); await driver.waitFor(find.text(chatCreate)); // Check newContact. - await driver.tap(find.pageBack()); + await driver.tap(pageBack); // Check searchChat Invoker.current.heartbeat(); await driver.tap(find.byValueKey(keyChatListSearchIconButton)); diff --git a/test_driver/profile_test.dart b/test_driver/profile_test.dart index 48b8c1f2..fd6c269b 100644 --- a/test_driver/profile_test.dart +++ b/test_driver/profile_test.dart @@ -43,11 +43,12 @@ // Imports the Flutter Driver API. import 'package:flutter_driver/flutter_driver.dart'; import 'package:ox_coi/src/utils/keyMapping.dart'; +import 'package:test/test.dart'; +import 'package:test_api/src/backend/invoker.dart'; + import 'setup/global_consts.dart'; import 'setup/helper_methods.dart'; import 'setup/main_test_setup.dart'; -import 'package:test/test.dart'; -import 'package:test_api/src/backend/invoker.dart'; void main() { group('Ox coi test.', () { @@ -55,24 +56,21 @@ void main() { Setup setup = new Setup(driver); setup.main(timeout); - SerializableFinder userSettingsUsernameLabelFinder = - find.byValueKey(keyUserSettingsUserSettingsUsernameLabel); - SerializableFinder userProfileUserNameTextFinder = - find.text(testUserNameUserProfile); - SerializableFinder userProfileEmailTextFinder = - find.byValueKey(keyUserProfileEmailText); - SerializableFinder userProfileStatusTextFinder = - find.text(profileUserStatus); + SerializableFinder userSettingsUsernameLabelFinder = find.byValueKey(keyUserSettingsUserSettingsUsernameLabel); + SerializableFinder userProfileUserNameTextFinder = find.text(testUserNameUserProfile); + SerializableFinder userProfileEmailTextFinder = find.byValueKey(keyUserProfileEmailText); + SerializableFinder userProfileStatusTextFinder = find.text(profileUserStatus); test('Test create profile integration tests.', () async { await getAuthentication( - setup.driver, - signInFinder, - coiDebugProviderFinder, - providerEmailFinder, - realEmail, - providerPasswordFinder, - realPassword); + setup.driver, + signInFinder, + coiDebugProviderFinder, + providerEmailFinder, + realEmail, + providerPasswordFinder, + realPassword, + ); await catchScreenshot(setup.driver, 'screenshots/signInDone.png'); await setup.driver.waitFor(chatWelcomeFinder); diff --git a/test_driver/setup/global_consts.dart b/test_driver/setup/global_consts.dart index d6e9108f..3e3898e5 100644 --- a/test_driver/setup/global_consts.dart +++ b/test_driver/setup/global_consts.dart @@ -55,7 +55,7 @@ const testUserNameUserProfile = 'EDN tester'; const realPassword = 'secret'; -const coiDebug = 'Coi debug'; +const coiDebug = 'Debug (mobile-qa)'; const meContact = 'Me'; @@ -99,7 +99,7 @@ const searchString = 'Douglas0'; const typeSomethingComposePlaceholder = 'Type something...'; -const helloWord = 'Hello word'; +const helloWorld = 'Hello word'; final typeSomethingComposePlaceholderFinder = find.byValueKey(typeSomethingComposePlaceholder); @@ -111,6 +111,10 @@ final chatWelcomeFinder = find.text(chatWelcomeMessage); final profileFinder = find.text(profile); +final pageBack = find.pageBack(); + +final helloWorldFinder = find.text(helloWorld); + final contactsFinder = find.text(contacts); final chatsFinder = find.text(chat); diff --git a/test_driver/setup/helper_methods.dart b/test_driver/setup/helper_methods.dart index 240bb14b..70002a03 100644 --- a/test_driver/setup/helper_methods.dart +++ b/test_driver/setup/helper_methods.dart @@ -40,11 +40,13 @@ * for more details. */ +import 'dart:io'; + import 'package:flutter_driver/flutter_driver.dart'; +import 'package:ox_coi/src/l10n/l.dart'; import 'package:ox_coi/src/utils/keyMapping.dart'; import 'package:test_api/src/backend/invoker.dart'; -import 'dart:io'; -import 'package:ox_coi/src/l10n/l.dart'; + import 'global_consts.dart'; FlutterDriver driver; @@ -58,15 +60,17 @@ Future catchScreenshot(FlutterDriver driver, String path) async { } Future getAuthentication( - FlutterDriver driver, - SerializableFinder signInFinder, - SerializableFinder coiDebugProviderFinder, - SerializableFinder email, - String fakeEmail, - SerializableFinder password, - String realPassword) async { + FlutterDriver driver, + SerializableFinder signInFinder, + SerializableFinder coiDebugProviderFinder, + SerializableFinder email, + String fakeEmail, + SerializableFinder password, + String realPassword, +) async { print('\nReal authentication.'); await driver.tap(signInFinder); + await driver.scroll(find.text(mailCom), 0, -600, Duration(milliseconds: 500)); await driver.tap(coiDebugProviderFinder); await driver.tap(email); await driver.enterText(fakeEmail); @@ -90,13 +94,14 @@ Future navigateTo(FlutterDriver driver, String pageToNavigate) async { } Future addNewContact( - FlutterDriver driver, - SerializableFinder personAddFinder, - SerializableFinder keyContactChangeNameFinder, - String newTestName, - SerializableFinder keyContactChangeEmailFinder, - String newTestContact, - SerializableFinder keyContactChangeCheckFinder) async { + FlutterDriver driver, + SerializableFinder personAddFinder, + SerializableFinder keyContactChangeNameFinder, + String newTestName, + SerializableFinder keyContactChangeEmailFinder, + String newTestContact, + SerializableFinder keyContactChangeCheckFinder, +) async { Invoker.current.heartbeat(); await driver.tap(personAddFinder); await catchScreenshot(driver, 'screenshots/person_add01.png'); @@ -118,17 +123,17 @@ Future deleteContact( ) async { await driver.tap(find.text(newTestName)); Invoker.current.heartbeat(); - await driver - .tap(find.byValueKey(keyContactDetailDeleteContactProfileActionIcon)); + await driver.tap(find.byValueKey(keyContactDetailDeleteContactProfileActionIcon)); await driver.tap(positiveFinder); } Future chatSearch( - FlutterDriver driver, - String chatName, - String searchString, - SerializableFinder keyChatListSearchIconButton, - String keySearchReturnIconButton) async { + FlutterDriver driver, + String chatName, + String searchString, + SerializableFinder keyChatListSearchIconButton, + String keySearchReturnIconButton, +) async { Invoker.current.heartbeat(); final searchReturnIconButton = find.byValueKey(keySearchReturnIconButton); await driver.tap(keyChatListSearchIconButton); @@ -136,15 +141,16 @@ Future chatSearch( await driver.enterText(searchString); await catchScreenshot(driver, 'screenshots/searchList.png'); await driver.tap(find.text(chatName)); - await driver.tap(find.pageBack()); + await driver.tap(pageBack); await driver.tap(searchReturnIconButton); } Future chatTest( - FlutterDriver driver, - String chatName, - SerializableFinder typeSomethingComposePlaceholder, - String helloWord) async { + FlutterDriver driver, + String chatName, + SerializableFinder typeSomethingComposePlaceholder, + String helloWord, +) async { Invoker.current.heartbeat(); await driver.tap(find.text(chatName)); await writeChatFromChat(driver, helloWord); @@ -152,38 +158,84 @@ Future chatTest( } Future writeChatFromChat(FlutterDriver driver, String helloWord) async { + await writeTextInChat(driver, helloWord); + // Enter audio now. + await driver.tap(find.byValueKey(KeyChatComposerMixinOnRecordAudioPressedIcon)); + sleep(Duration(seconds: 1)); + await driver.tap(find.byValueKey(KeyChatComposerMixinOnRecordAudioSendIcon)); +} + +Future writeTextInChat(FlutterDriver driver, String helloWord) async { await driver.tap(typeSomethingComposePlaceholderFinder); await driver.enterText(helloWord); await driver.tap(find.byValueKey(KeyChatComposerMixinOnSendTextIcon)); - await driver.waitFor(find.text(helloWord)); - // Enter audio now. - await driver - .tap(find.byValueKey(KeyChatComposerMixinOnRecordAudioPressedIcon)); - sleep(Duration(seconds: 3)); - await driver.tap(find.byValueKey(KeyChatComposerMixinOnRecordAudioSendIcon)); + await driver.waitFor(helloWorldFinder); } Future callTest(FlutterDriver driver) async { await driver.tap(find.byValueKey(keyChatIconButtonIconPhone)); await catchScreenshot(driver, 'screenshots/callTest.png'); await driver.tap(keyDialogBuilderAlertDialogOkFlatButtonFinder); - await driver.tap(find.pageBack()); } -Future blockOneContact(FlutterDriver driver, String contactNameToBlock) async { - await driver.tap(find.text(contactNameToBlock)); - await driver - .tap(find.byValueKey(keyContactDetailBlockContactProfileActionIcon)); - await driver.tap(find.text(blockContact)); - await catchScreenshot(driver, 'screenshots/contactListAfterBlock.png'); - await driver.waitForAbsent(find.text(contactNameToBlock)); - await driver.tap(find.byValueKey(keyContactListBlockIconButton)); - await driver.waitFor(find.text(contactNameToBlock)); - await catchScreenshot(driver, 'screenshots/blockedList.png'); - await driver.tap(find.text(contactNameToBlock)); +Future unblockOneContactFromBlockedContacts( + FlutterDriver driver, + String contactNameToUnblock, +) async { + await driver.tap(find.text(contactNameToUnblock)); await driver.tap(find.text(unblock)); await catchScreenshot(driver, 'screenshots/blockedListNew.png'); await driver.waitFor(find.text(L.getKey(L.contactNoBlocked))); await driver.tap(find.byValueKey(keyContactBlockedListCloseIconButton)); - await driver.waitFor(find.text(contactNameToBlock)); +} + +Future blockOneContactFromContacts(FlutterDriver driver, String contactNameToBlock) async { + await driver.tap(find.text(contactNameToBlock)); + await driver.tap(find.byValueKey(keyContactDetailBlockContactProfileActionIcon)); + await driver.tap(find.text(blockContact)); + await catchScreenshot(driver, 'screenshots/contactListAfterBlock.png'); +} + +Future unFlaggedMessage( + FlutterDriver driver, + String flagUnFlag, + SerializableFinder messageToUnFlaggedFinder, +) async { + await driver.tap(find.byValueKey(keyChatListGetFlaggedActionIconButton)); + await driver.waitFor(messageToUnFlaggedFinder); + await driver.scroll(messageToUnFlaggedFinder, 0, 0, Duration(milliseconds: 5000)); + await driver.tap(find.text(flagUnFlag)); +} + +Future flaggedMessage( + FlutterDriver driver, + String flagUnFlag, + SerializableFinder messageToFlaggedFinder, +) async { + await driver.scroll(messageToFlaggedFinder, 0, 0, Duration(milliseconds: 5000)); + await driver.tap(find.text(flagUnFlag)); +} + +Future deleteMessage(SerializableFinder textToDeleteFinder, FlutterDriver driver) async { + await driver.scroll(textToDeleteFinder, 0, 0, Duration(milliseconds: 5000)); + await driver.tap(find.text('Delete locally')); + await catchScreenshot(driver, 'screenshots/chatAfterdDelete.png'); +} + +Future copyAndPasteMessage(FlutterDriver driver, String copy, String paste) async { + await driver.scroll(helloWorldFinder, 0, 0, Duration(milliseconds: 5000)); + await driver.tap(find.text(copy)); + await driver.scroll(typeSomethingComposePlaceholderFinder, 0, 0, Duration(milliseconds: 5000)); + await driver.tap(find.text(paste)); + await driver.tap(find.byValueKey(KeyChatComposerMixinOnSendTextIcon)); + if (helloWorldFinder.serialize().length <= 2) { + print('Copy paste succeed'); + await catchScreenshot(driver, 'screenshots/chatAfterPaste.png'); + } +} + +Future forwardMessageTo(FlutterDriver driver, String contactToForward, String forward) async { + await driver.scroll(helloWorldFinder, 0, 0, Duration(milliseconds: 5000)); + await driver.tap(find.text(forward)); + await driver.tap(find.text(contactToForward)); } diff --git a/test_driver/setup/main_test_setup.dart b/test_driver/setup/main_test_setup.dart index 8f02512d..672f598a 100644 --- a/test_driver/setup/main_test_setup.dart +++ b/test_driver/setup/main_test_setup.dart @@ -40,8 +40,9 @@ * for more details. */ -import 'package:flutter_driver/flutter_driver.dart'; import 'dart:io'; + +import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart'; class Setup { @@ -56,48 +57,66 @@ class Setup { main(Duration timeout) { setUpAll(() async { final String adbPath = 'adb'; - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.openxchange.oxcoi.dev', - 'android.permission.RECORD_AUDIO' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.openxchange.oxcoi.dev', - 'android.permission.READ_EXTERNAL_STORAGE' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.openxchange.oxcoi.dev', - 'android.permission.WRITE_EXTERNAL_STORAGE' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.openxchange.oxcoi.dev', - 'android.permission.WRITE_CONTACTS' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.openxchange.oxcoi.dev', - 'android.permission.READ_CONTACTS' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.openxchange.oxcoi.dev', - 'android.permission.RECORD_AUDIO' - ]); + await Process.run( + adbPath, + [ + 'shell', + 'pm', + 'grant', + 'com.openxchange.oxcoi.dev', + 'android.permission.RECORD_AUDIO', + ], + ); + await Process.run( + adbPath, + [ + 'shell', + 'pm', + 'grant', + 'com.openxchange.oxcoi.dev', + 'android.permission.READ_EXTERNAL_STORAGE', + ], + ); + await Process.run( + adbPath, + [ + 'shell', + 'pm', + 'grant', + 'com.openxchange.oxcoi.dev', + 'android.permission.WRITE_EXTERNAL_STORAGE', + ], + ); + await Process.run( + adbPath, + [ + 'shell', + 'pm', + 'grant', + 'com.openxchange.oxcoi.dev', + 'android.permission.WRITE_CONTACTS', + ], + ); + await Process.run( + adbPath, + [ + 'shell', + 'pm', + 'grant', + 'com.openxchange.oxcoi.dev', + 'android.permission.READ_CONTACTS', + ], + ); + await Process.run( + adbPath, + [ + 'shell', + 'pm', + 'grant', + 'com.openxchange.oxcoi.dev', + 'android.permission.RECORD_AUDIO', + ], + ); this._drivers = await FlutterDriver.connect(); this._drivers.setSemantics(true, timeout: timeout);