public void test08ConcurrentFileTransfers() throws IOException {
    checkThatTheFilesHaveNotBeenTransferred();

    albert.changeNickName("Albino");
    tina.changeNickName("TinaBurger");
    xen.changeNickName("XenXei");
    solo.sleep(500);

    albert.sendFile(me, image.getFile());
    solo.sleep(500);
    checkActiveFileTransferNotifications(7);

    xen.sendFile(me, image.getFile());
    solo.sleep(500);
    checkActiveFileTransferNotifications(7, 8);

    tina.sendFile(me, image.getFile());
    solo.sleep(500);
    checkActiveFileTransferNotifications(7, 8, 9);

    checkMainChatMessage("*** Albino is trying to send the file kouchat-1600x1600.png");
    checkMainChatMessage("*** TinaBurger is trying to send the file kouchat-1600x1600.png");
    checkMainChatMessage("*** XenXei is trying to send the file kouchat-1600x1600.png");

    openReceiveFileDialog(albert, 7);
    acceptFileTransfer();
    solo.sleep(100);

    openReceiveFileDialog(xen, 8);
    acceptFileTransfer();
    solo.sleep(100);

    openReceiveFileDialog(tina, 9);
    acceptFileTransfer();
    solo.sleep(1000);

    checkThatTheMainChatIsInFront();
    checkThatNoFileTransferNotificationsAreActive();

    // Depending on screen size, some of the messages might have scrolled by, currently making them
    // invisible.
    checkPastMainChatMessage("*** Receiving kouchat-1600x1600.png from Albino");
    checkPastMainChatMessage(
        "*** Successfully received kouchat-1600x1600.png from Albino, and saved as kouchat-1600x1600.png");

    checkPastMainChatMessage("*** Receiving kouchat-1600x1600.png from XenXei");
    checkPastMainChatMessage(
        "*** Successfully received kouchat-1600x1600.png from XenXei, and saved as kouchat-1600x1600_1.png");

    checkMainChatMessage("*** Receiving kouchat-1600x1600.png from TinaBurger");
    checkMainChatMessage(
        "*** Successfully received kouchat-1600x1600.png from TinaBurger, and saved as kouchat-1600x1600_2.png");

    checkThatTheFileWasReceivedSuccessfully(requestedFile);
    checkThatTheFileWasReceivedSuccessfully(requestedFile1);
    checkThatTheFileWasReceivedSuccessfully(requestedFile2);
    solo.sleep(500);
  }
  public void test06CancelFileTransferRequestBeforeAccepting() {
    checkThatTheFilesHaveNotBeenTransferred();

    tina.changeNickName("SuperTina");
    solo.sleep(500);

    tina.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** SuperTina is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(5);
    solo.sleep(500);

    openReceiveFileDialog(tina, 5);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "SuperTina is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    tina.cancelFileSending(me, image.getFile());
    solo.sleep(500);

    acceptFileTransfer();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkMainChatMessage("*** SuperTina aborted sending of kouchat-1600x1600.png");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
  public void test05CancelFileTransferRequestBeforeRejecting() {
    checkThatTheFilesHaveNotBeenTransferred();

    xen.changeNickName("XenMaster");
    solo.sleep(500);

    xen.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** XenMaster is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(4);
    solo.sleep(500);

    openReceiveFileDialog(xen, 4);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "XenMaster is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    xen.cancelFileSending(me, image.getFile());
    solo.sleep(500);

    rejectFileTransfer();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkMainChatMessage("*** XenMaster aborted sending of kouchat-1600x1600.png");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
  public void test03AcceptFileTransferRequest() throws IOException {
    checkThatTheFilesHaveNotBeenTransferred();

    albert.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** Albert is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(2);
    solo.sleep(500);

    openReceiveFileDialog(albert, 2);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Albert is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    acceptFileTransfer();
    solo.sleep(1000);

    checkThatTheMainChatIsInFront();
    checkMainChatMessage("*** Receiving kouchat-1600x1600.png from Albert");
    checkMainChatMessage(
        "*** Successfully received kouchat-1600x1600.png from Albert, and saved as kouchat-1600x1600.png");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFileWasReceivedSuccessfully(requestedFile);
    solo.sleep(500);
  }
  public void test02RejectFileTransferRequest() {
    checkThatTheFilesHaveNotBeenTransferred();

    tina.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** Tina is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(1);
    solo.sleep(500);

    openReceiveFileDialog(tina, 1);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Tina is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    rejectFileTransfer();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkMainChatMessage("*** You declined to receive kouchat-1600x1600.png from Tina");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
  public void test07CloseAndReopenDialog() {
    checkThatTheFilesHaveNotBeenTransferred();

    albert.changeNickName("Alban");
    solo.sleep(500);

    albert.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** Alban is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(6);
    solo.sleep(500);

    // First try
    openReceiveFileDialog(albert, 6);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Alban is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    // Close dialog without accepting or rejecting
    solo.goBack();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkActiveFileTransferNotifications(6); // The notification should still be there

    // Second try
    openReceiveFileDialog(albert, 6);
    solo.sleep(500);

    checkThatTheDialogIsInFront();
    checkDialogMessage(
        "Alban is trying to send you the file ‘kouchat-1600x1600.png’ (67.16KB). "
            + "Do you want to accept the file transfer?");
    solo.sleep(500);

    rejectFileTransfer();
    solo.sleep(500);

    checkThatTheMainChatIsInFront();
    checkMainChatMessage("*** You declined to receive kouchat-1600x1600.png from Alban");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
  public void test04CancelFileTransferRequestBeforeOpeningActivity() {
    checkThatTheFilesHaveNotBeenTransferred();

    xen.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** Xen is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(3);
    solo.sleep(500);

    xen.cancelFileSending(me, image.getFile());

    solo.sleep(1000);
    checkMainChatMessage("*** Xen aborted sending of kouchat-1600x1600.png");
    checkThatNoFileTransferNotificationsAreActive();
    checkThatTheFilesHaveNotBeenTransferred();
  }
  public void test09UserLoggingOffShouldCancelFileTransferRequest() {
    checkThatTheFilesHaveNotBeenTransferred();

    tina.changeNickName("TinaTurner");
    solo.sleep(500);

    tina.sendFile(me, image.getFile());
    solo.sleep(500);

    checkMainChatMessage("*** TinaTurner is trying to send the file kouchat-1600x1600.png");
    checkActiveFileTransferNotifications(10);
    solo.sleep(500);

    tina.logoff();
    solo.sleep(1000);

    checkMainChatMessage("*** TinaTurner logged off");
    checkThatNoFileTransferNotificationsAreActive();
  }