| 2696 | } |
| 2697 | |
| 2698 | func TestHandleSessionUpdateUserAgent(t *testing.T) { |
| 2699 | topicName := "usrMe" |
| 2700 | numUsers := 1 |
| 2701 | helper := TopicTestHelper{} |
| 2702 | helper.setUp(t, numUsers, types.TopicCatMe, topicName /*attach=*/, true) |
| 2703 | defer helper.tearDown() |
| 2704 | |
| 2705 | uid := helper.uids[0] |
| 2706 | supd := &sessionUpdate{ |
| 2707 | userAgent: "newUA", |
| 2708 | } |
| 2709 | uaAgent := "oldUA" |
| 2710 | timer := time.NewTimer(time.Hour) |
| 2711 | helper.topic.handleSessionUpdate(supd, &uaAgent, timer) |
| 2712 | helper.finish() |
| 2713 | |
| 2714 | // Check for errors from testHubLoop |
| 2715 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 2716 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 2717 | } |
| 2718 | |
| 2719 | // online count stays 1. |
| 2720 | if online := helper.topic.perUser[uid].online; online != 1 { |
| 2721 | t.Errorf("online count for %s: expected 1, found %d", uid.UserId(), online) |
| 2722 | } |
| 2723 | if uaAgent != "newUA" { |
| 2724 | t.Errorf("User agent: expected 'newUA', found '%s'", uaAgent) |
| 2725 | } |
| 2726 | timer.Stop() |
| 2727 | } |
| 2728 | |
| 2729 | func TestHandleUATimerEvent(t *testing.T) { |
| 2730 | topicName := "usrMe" |