Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Jan 19, 2024
2 parents 20c402b + 41da705 commit 39cbe2a
Show file tree
Hide file tree
Showing 34 changed files with 2,539 additions and 197 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v1

- name: Set configuration env
shell: pwsh
Expand All @@ -43,7 +43,7 @@ jobs:
msbuild /target:restore,build "/p:Configuration=$($env:CONFIGURATION)" /verbosity:minimal ${{ inputs.msbuild_args }}
- name: Upload build result
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
path: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: '${{ github.event.pull_request.head.sha }}'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v1

- name: Set configuration env
shell: pwsh
Expand All @@ -37,7 +37,7 @@ jobs:
}
- name: Restore build result
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build

Expand All @@ -50,7 +50,7 @@ jobs:
.\tools\build-zip-archive.ps1 -BinDir $binDir -DestPath $destPath
- name: Upload build result
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: package
path: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v1

- name: Set configuration env
shell: pwsh
Expand All @@ -41,7 +41,7 @@ jobs:
nuget-
- name: Restore build result
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build

Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
exit $p.ExitCode
}
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4.0.0-beta.3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
更新履歴

==== Ver 3.12.0(2024/01/20)
* NEW: graphqlエンドポイントを使用したホームタイムラインの取得に対応

==== Ver 3.11.0(2024/01/07)
* NEW: Cookie使用時の関連発言表示に対応
* FIX: APIリクエストのタイムアウト時に接続が切断されない場合がある不具合を修正
Expand Down
96 changes: 96 additions & 0 deletions OpenTween.Tests/Api/GraphQL/HomeLatestTimelineRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// OpenTween - Client of Twitter
// Copyright (c) 2023 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// 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 GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using System.Threading.Tasks;
using Moq;
using OpenTween.Connection;
using Xunit;

namespace OpenTween.Api.GraphQL
{
public class HomeLatestTimelineRequestTest
{
[Fact]
public async Task Send_Test()
{
using var apiResponse = await TestUtils.CreateApiResponse("Resources/Responses/HomeLatestTimeline.json");

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.SendAsync(It.IsAny<IHttpRequest>())
)
.Callback<IHttpRequest>(x =>
{
var request = Assert.IsType<GetRequest>(x);
Assert.Equal(new("https://twitter.com/i/api/graphql/lAKISuk_McyDUlhS2Zmv4A/HomeLatestTimeline"), request.RequestUri);
var query = request.Query!;
Assert.Equal(2, query.Count);
Assert.Equal("""{"includePromotedContent":true,"latestControlAvailable":true,"requestContext":"launch","count":20}""", query["variables"]);
Assert.True(query.ContainsKey("features"));
Assert.Equal("HomeLatestTimeline", request.EndpointName);
})
.ReturnsAsync(apiResponse);

var request = new HomeLatestTimelineRequest
{
Count = 20,
};

var response = await request.Send(mock.Object);
Assert.Single(response.Tweets);
Assert.Equal("DAABCgABGENe-W5AJxEKAAIWeWboXhcQAAgAAwAAAAEAAA", response.CursorTop);
Assert.Equal("DAABCgABGENe-W4__5oKAAIWK_5v3BcQAAgAAwAAAAIAAA", response.CursorBottom);

mock.VerifyAll();
}

[Fact]
public async Task Send_RequestCursor_Test()
{
using var apiResponse = await TestUtils.CreateApiResponse("Resources/Responses/HomeLatestTimeline.json");

var mock = new Mock<IApiConnection>();
mock.Setup(x =>
x.SendAsync(It.IsAny<IHttpRequest>())
)
.Callback<IHttpRequest>(x =>
{
var request = Assert.IsType<GetRequest>(x);
Assert.Equal(new("https://twitter.com/i/api/graphql/lAKISuk_McyDUlhS2Zmv4A/HomeLatestTimeline"), request.RequestUri);
var query = request.Query!;
Assert.Equal(2, query.Count);
Assert.Equal("""{"includePromotedContent":true,"latestControlAvailable":true,"requestContext":"launch","count":20,"cursor":"aaa"}""", query["variables"]);
Assert.True(query.ContainsKey("features"));
Assert.Equal("HomeLatestTimeline", request.EndpointName);
})
.ReturnsAsync(apiResponse);

var request = new HomeLatestTimelineRequest
{
Count = 20,
Cursor = "aaa",
};

await request.Send(mock.Object);
mock.VerifyAll();
}
}
}
108 changes: 105 additions & 3 deletions OpenTween.Tests/DetailsListViewTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
// Boston, MA 02110-1301, USA.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTween.OpenTweenCustomControl;
using Xunit;

Expand All @@ -36,5 +33,110 @@ public void Initialize_Test()
{
using var listView = new DetailsListView();
}

[WinFormsFact]
public void SelectionMark_Test()
{
using var listView = new DetailsListView();

listView.RetrieveVirtualItem += (s, e) => e.Item = new();
listView.VirtualMode = true;
listView.VirtualListSize = 10;
listView.CreateControl();

listView.SelectionMark = 3;
Assert.Equal(3, listView.SelectionMark);
}

[WinFormsFact]
public void SelectItems_EmptyTest()
{
using var listView = new DetailsListView();

listView.RetrieveVirtualItem += (s, e) => e.Item = new();
listView.VirtualMode = true;
listView.VirtualListSize = 10;
listView.CreateControl();

listView.SelectedIndices.Add(1);
Assert.Single(listView.SelectedIndices);

listView.SelectItems(Array.Empty<int>());
Assert.Empty(listView.SelectedIndices);
}

[WinFormsFact]
public void SelectItems_SingleTest()
{
using var listView = new DetailsListView();

listView.RetrieveVirtualItem += (s, e) => e.Item = new();
listView.VirtualMode = true;
listView.VirtualListSize = 10;
listView.CreateControl();

listView.SelectedIndices.Add(1);
Assert.Single(listView.SelectedIndices);

listView.SelectItems(new[] { 2 });
Assert.Equal(new[] { 2 }, listView.SelectedIndices.Cast<int>());
}

[WinFormsFact]
public void SelectItems_Multiple_ClearAndSelectTest()
{
using var listView = new DetailsListView();

listView.RetrieveVirtualItem += (s, e) => e.Item = new();
listView.VirtualMode = true;
listView.VirtualListSize = 10;
listView.CreateControl();

listView.SelectedIndices.Add(2);
listView.SelectedIndices.Add(3);
Assert.Equal(2, listView.SelectedIndices.Count);

// Clear して選択し直した方が早いパターン
listView.SelectItems(new[] { 5, 6 });
Assert.Equal(new[] { 5, 6 }, listView.SelectedIndices.Cast<int>());
}

[WinFormsFact]
public void SelectItems_Multiple_DeselectAndSelectTest()
{
using var listView = new DetailsListView();

listView.RetrieveVirtualItem += (s, e) => e.Item = new();
listView.VirtualMode = true;
listView.VirtualListSize = 10;
listView.CreateControl();

listView.SelectedIndices.Add(1);
listView.SelectedIndices.Add(2);
listView.SelectedIndices.Add(3);
Assert.Equal(3, listView.SelectedIndices.Count);

// 選択範囲の差分だけ更新した方が早いパターン
listView.SelectItems(new[] { 2, 3, 4 });
Assert.Equal(new[] { 2, 3, 4 }, listView.SelectedIndices.Cast<int>());
}

[WinFormsFact]
public void SelectItems_OutOfRangeTest()
{
using var listView = new DetailsListView();

listView.RetrieveVirtualItem += (s, e) => e.Item = new();
listView.VirtualMode = true;
listView.VirtualListSize = 10;
listView.CreateControl();

Assert.Throws<ArgumentOutOfRangeException>(
() => listView.SelectItems(new[] { -1 })
);
Assert.Throws<ArgumentOutOfRangeException>(
() => listView.SelectItems(new[] { 10 })
);
}
}
}
54 changes: 54 additions & 0 deletions OpenTween.Tests/ListElementTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// OpenTween - Client of Twitter
// Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
// All rights reserved.
//
// This file is part of OpenTween.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
//
// 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 GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.

using Xunit;

namespace OpenTween
{
public class ListElementTest
{
[Fact]
public void ToString_PublicTest()
{
var list = new ListElement
{
Id = 12345L,
Name = "tetete",
Username = "opentween",
IsPublic = true,
};
Assert.Equal("@opentween/tetete [Public]", list.ToString());
}

[Fact]
public void ToString_ProtectedTest()
{
var list = new ListElement
{
Id = 12345L,
Name = "tetete",
Username = "opentween",
IsPublic = false,
};
Assert.Equal("@opentween/tetete [Protected]", list.ToString());
}
}
}
Loading

0 comments on commit 39cbe2a

Please sign in to comment.