Skip to content

Commit

Permalink
TweenMain.RefreshTimelineメソッドに対するテストコード
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Jan 10, 2024
1 parent d359f51 commit 16f128e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions OpenTween.Tests/TweenMainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
Expand Down Expand Up @@ -55,6 +56,11 @@ private void UsingTweenMain(Action<TweenMain, TestContext> func)
using var iconAssets = new IconAssetsManager();
var thumbnailGenerator = new ThumbnailGenerator(new(autoupdate: false));

// TabInformation.GetInstance() で取得できるようにする
var field = typeof(TabInformations).GetField("Instance",
BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.SetField);
field.SetValue(null, tabinfo);

using var tweenMain = new TweenMain(settings, tabinfo, twitter, imageCache, iconAssets, thumbnailGenerator);
var context = new TestContext(settings, tabinfo);

Expand Down Expand Up @@ -174,6 +180,36 @@ public void AddNewTab_PublicSearchTabTest()
});
}

[WinFormsFact]
public void RefreshTimeline_Test()
{
this.UsingTweenMain((tweenMain, context) =>
{
var tabPage = tweenMain.ListTab.TabPages[0];
Assert.Equal("Recent", tabPage.Text);

var listView = (DetailsListView)tabPage.Controls[0];
Assert.Equal(0, listView.VirtualListSize);

var post = new PostClass
{
StatusId = new TwitterStatusId("100"),
Text = "hoge",
UserId = 111L,
ScreenName = "opentween",
CreatedAt = new(2024, 1, 1, 0, 0, 0),
};
context.TabInfo.AddPost(post);
context.TabInfo.DistributePosts();
tweenMain.RefreshTimeline();

Assert.Equal(1, listView.VirtualListSize);

var listItem = listView.Items[0];
Assert.Equal("opentween", listItem.SubItems[4].Text);
});
}

[WinFormsFact]
public void FormatStatusText_NewLineTest()
{
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/Tween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ internal void MarkSettingAtIdModified()
_ = this.saveConfigDebouncer.Call();
}

private void RefreshTimeline()
internal void RefreshTimeline()
{
var curListView = this.CurrentListView;

Expand Down

0 comments on commit 16f128e

Please sign in to comment.