コード例 #1
0
    public void ReactCorrectlyToReportClick()
    {
        var id    = "test-id-1";
        var entry = TestHelpers_Friends.FakeAddFriend(friendsController, view, id);

        bool reportPlayerSent = false;

        Action <string, string> callback =
            (name, payload) =>
        {
            if (name == "ReportPlayer")
            {
                reportPlayerSent = true;
            }
        };

        WebInterface.OnMessageFromEngine += callback;

        entry.menuButton.onClick.Invoke();

        Assert.IsTrue(controller.view.friendsList.contextMenuPanel.gameObject.activeSelf);

        controller.view.friendsList.contextMenuPanel.reportButton.onClick.Invoke();

        Assert.IsTrue(reportPlayerSent);

        WebInterface.OnMessageFromEngine -= callback;
    }
コード例 #2
0
    public void TaskbarNotificationBadgeHasCorrectValue()
    {
        PlayerPrefs.SetInt(FriendsHUDController.PLAYER_PREFS_SEEN_FRIEND_COUNT, 0);

        var friendsRequestBadge = GetBadge("NotificationBadge_FriendsRequestTab");
        var friendsTaskbarBadge = GetBadge("NotificationBadge_FriendsButton");

        controller.SetVisibility(false);

        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-1");
        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-2");
        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-3");
        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-4");
        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-5", FriendshipAction.REQUESTED_FROM);

        Assert.AreEqual(1, friendsRequestBadge.finalValue);
        Assert.AreEqual(5, friendsTaskbarBadge.finalValue);

        controller.SetVisibility(true);

        Assert.AreEqual(1, friendsRequestBadge.finalValue);
        Assert.AreEqual(1, friendsTaskbarBadge.finalValue);

        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-5", FriendshipAction.APPROVED);
        TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-6", FriendshipAction.REQUESTED_FROM);

        Assert.AreEqual(1, friendsRequestBadge.finalValue);
        Assert.AreEqual(1, friendsTaskbarBadge.finalValue);

        UnityEngine.Object.Destroy(friendsRequestBadge.gameObject);
        UnityEngine.Object.Destroy(friendsTaskbarBadge.gameObject);
    }
コード例 #3
0
    public IEnumerator TaskbarNotificationBadgeHasCorrectValue()
    {
        PlayerPrefsUtils.SetInt(FriendsHUDController.PLAYER_PREFS_SEEN_FRIEND_COUNT, 0);

        var friendsRequestBadge = GetBadge("NotificationBadge_FriendsRequestTab");
        var friendsTaskbarBadge = GetBadge("NotificationBadge_FriendsButton");

        controller.SetVisibility(false);

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-1"));

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-2"));

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-3"));

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-4"));

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-5", FriendshipAction.REQUESTED_FROM));

        Assert.AreEqual(1, friendsRequestBadge.finalValue);
        Assert.AreEqual(5, friendsTaskbarBadge.finalValue);

        controller.SetVisibility(true);

        Assert.AreEqual(1, friendsRequestBadge.finalValue);
        Assert.AreEqual(1, friendsTaskbarBadge.finalValue);

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-5", FriendshipAction.APPROVED));

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, "friend-6", FriendshipAction.REQUESTED_FROM));

        Assert.AreEqual(1, friendsRequestBadge.finalValue);
        Assert.AreEqual(1, friendsTaskbarBadge.finalValue);
    }
コード例 #4
0
    public void ReactCorrectlyToWhisperClick()
    {
        var id    = "test-id-1";
        var entry = TestHelpers_Friends.FakeAddFriend(friendsController, view, id);

        bool pressedWhisper = false;

        controller.OnPressWhisper += (x) => { pressedWhisper = x == id; };
        entry.whisperButton.onClick.Invoke();
        Assert.IsTrue(pressedWhisper);
    }
コード例 #5
0
    public void ReactCorrectlyToFriendApproved()
    {
        var id    = "test-id-1";
        var entry = TestHelpers_Friends.FakeAddFriend(friendsController, view, id);

        Assert.IsNotNull(entry);

        friendsController.RaiseUpdateFriendship(id, FriendshipAction.DELETED);
        entry = controller.view.friendsList.GetEntry(id) as FriendEntry;
        Assert.IsNull(entry);
    }
コード例 #6
0
    public void ReactCorrectlyToPassportClick()
    {
        var id    = "test-id-1";
        var entry = TestHelpers_Friends.FakeAddFriend(friendsController, view, id);

        var currentPlayerId = Resources.Load <StringVariable>(UserContextMenu.CURRENT_PLAYER_ID);

        entry.menuButton.onClick.Invoke();
        Assert.AreNotEqual(id, currentPlayerId.Get());

        view.friendsList.contextMenuPanel.passportButton.onClick.Invoke();

        Assert.AreEqual(id, currentPlayerId.Get());
    }
コード例 #7
0
    public void ReactCorrectlyToFriendCancelled()
    {
        var id = "test-id-1";

        TestHelpers_Friends.FakeAddFriend(friendsController, view, id);

        friendsController.RaiseUpdateFriendship(id, FriendshipAction.REQUESTED_TO);
        var entry = controller.view.friendRequestsList.GetEntry(id);

        Assert.IsNotNull(entry);
        friendsController.RaiseUpdateFriendship(id, FriendshipAction.CANCELLED);
        entry = controller.view.friendRequestsList.GetEntry(id);
        Assert.IsNull(entry);
    }
コード例 #8
0
    public IEnumerator ReactCorrectlyToWhisperClick()
    {
        var id = "test-id-1";

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, id));

        var entry = TestHelpers_Friends.GetEntry(view, id);

        Assert.IsNotNull(entry);

        bool pressedWhisper = false;

        controller.OnPressWhisper += (x) => { pressedWhisper = x == id; };
        entry.whisperButton.onClick.Invoke();
        Assert.IsTrue(pressedWhisper);
    }
コード例 #9
0
    public IEnumerator ReactCorrectlyToFriendRejected()
    {
        var id = "test-id-1";

        yield return(TestHelpers_Friends.FakeAddFriend(friendsController, view, id));

        var fentry = TestHelpers_Friends.GetEntry(view, id);

        Assert.IsNotNull(fentry);

        friendsController.RaiseUpdateFriendship(id, FriendshipAction.REQUESTED_FROM);
        friendsController.RaiseUpdateFriendship(id, FriendshipAction.REJECTED);

        var entry = controller.view.friendRequestsList.GetEntry(id);

        Assert.IsNull(entry);
    }
コード例 #10
0
    public void ToggleWindowsProperly()
    {
        privateChatController = new PrivateChatWindowHUDController();
        privateChatController.Initialize(chatController);
        controller.AddPrivateChatWindow(privateChatController);

        const string badPositionMsg =
            "Anchored position should be zero or it won't be correctly placed inside the taskbar";
        const string badPivotMsg = "Pivot should be zero or it won't be correctly placed inside the taskbar";

        RectTransform rt = privateChatController.view.transform as RectTransform;

        Assert.AreEqual(Vector2.zero, rt.anchoredPosition, badPositionMsg);
        Assert.AreEqual(Vector2.zero, rt.pivot, badPivotMsg);

        worldChatWindowController = new WorldChatWindowHUDController();
        worldChatWindowController.Initialize(chatController, null);
        controller.AddWorldChatWindow(worldChatWindowController);

        rt = worldChatWindowController.view.transform as RectTransform;
        Assert.AreEqual(Vector2.zero, rt.anchoredPosition, badPositionMsg);
        Assert.AreEqual(Vector2.zero, rt.pivot, badPivotMsg);

        friendsHudController = new FriendsHUDController();
        friendsHudController.Initialize(friendsController, UserProfile.GetOwnUserProfile());
        controller.AddFriendsWindow(friendsHudController);

        rt = friendsHudController.view.transform as RectTransform;
        Assert.AreEqual(Vector2.zero, rt.anchoredPosition, badPositionMsg);
        Assert.AreEqual(Vector2.zero, rt.pivot, badPivotMsg);

        TestHelpers_Friends.FakeAddFriend(friendsController, friendsHudController.view, "test-1");
        TestHelpers_Chat.FakePrivateChatMessageFrom(chatController, "test-1", "test message!");

        var buttonList = view.GetButtonList();

        Assert.AreEqual(8, buttonList.Count, "Chat head is missing when receiving a private message?");

        Assert.IsFalse(view.chatButton.toggledOn);
        Assert.IsTrue(buttonList[2] is ChatHeadButton);

        ChatHeadButton headButton = buttonList[2] as ChatHeadButton;

        Assert.IsFalse(headButton.toggledOn);

        //NOTE(Brian): Toggle chat head on and test it works as intended
        headButton.toggleButton.onClick.Invoke();

        Assert.IsTrue(headButton.lineOnIndicator.isVisible);
        Assert.IsFalse(view.friendsButton.lineOnIndicator.isVisible);
        Assert.IsFalse(view.chatButton.lineOnIndicator.isVisible);
        Assert.IsTrue(controller.privateChatWindowHud.view.gameObject.activeInHierarchy);

        //NOTE(Brian): Toggle friends window on and test all other windows are untoggled
        view.friendsButton.toggleButton.onClick.Invoke();

        Assert.IsFalse(controller.privateChatWindowHud.view.gameObject.activeInHierarchy);
        Assert.IsFalse(headButton.lineOnIndicator.isVisible);
        Assert.IsTrue(view.friendsButton.lineOnIndicator.isVisible);
        Assert.IsFalse(view.chatButton.lineOnIndicator.isVisible);

        //NOTE(Brian): Toggle friends window off and test all other windows are untoggled
        view.friendsButton.toggleButton.onClick.Invoke();

        Assert.IsFalse(controller.privateChatWindowHud.view.gameObject.activeInHierarchy);
        Assert.IsFalse(headButton.lineOnIndicator.isVisible);
        Assert.IsFalse(view.friendsButton.lineOnIndicator.isVisible);

        //NOTE(Brian): Toggle friends on, and then chat button on. Then check if world chat window is showing up.
        view.friendsButton.toggleButton.onClick.Invoke();
        view.chatButton.toggleButton.onClick.Invoke();

        Assert.IsTrue(controller.worldChatWindowHud.view.gameObject.activeInHierarchy);
        Assert.IsFalse(controller.friendsHud.view.gameObject.activeInHierarchy);
        Assert.IsFalse(view.friendsButton.lineOnIndicator.isVisible);
    }