+
Skip to content

Refactor GdkPixbuf-2.0.Tests #1133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/GirCore.Libs.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"Samples\\WebKit-6.0\\JavascriptCallback\\JavascriptCallback.csproj",
"Tests\\Generation\\GirLoader.Tests\\GirLoader.Tests.csproj",
"Tests\\Libs\\Cairo-1.0.Tests\\Cairo-1.0.Tests.csproj",
"Tests\\Libs\\GdkPixbuf-2.0.Tests\\GdkPixbuf-2.0.Tests.csproj",
"Tests\\Libs\\Gio-2.0.Tests\\Gio-2.0.Tests.csproj",
"Tests\\Libs\\GLib-2.0.Tests\\GLib-2.0.Tests.csproj",
"Tests\\Libs\\GObject-2.0.Tests\\GObject-2.0.Tests.csproj",
Expand Down
15 changes: 0 additions & 15 deletions src/GirCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestLoading", "Samples\GdkP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gtk-4.0.Tests", "Tests\Libs\Gtk-4.0.Tests\Gtk-4.0.Tests.csproj", "{F86D983A-9881-4BE7-AF92-FA0CE41FB319}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GdkPixbuf-2.0.Tests", "Tests\Libs\GdkPixbuf-2.0.Tests\GdkPixbuf-2.0.Tests.csproj", "{61016ABA-608B-47FA-9FBD-CA17D24BAB89}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Generation", "Generation", "{7A05C10C-8797-4D29-A97A-F399316BE893}"
ProjectSection(SolutionItems) = preProject
Generation\Directory.Build.props = Generation\Directory.Build.props
Expand Down Expand Up @@ -471,18 +469,6 @@ Global
{F86D983A-9881-4BE7-AF92-FA0CE41FB319}.Release|x64.Build.0 = Release|Any CPU
{F86D983A-9881-4BE7-AF92-FA0CE41FB319}.Release|x86.ActiveCfg = Release|Any CPU
{F86D983A-9881-4BE7-AF92-FA0CE41FB319}.Release|x86.Build.0 = Release|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Debug|x64.ActiveCfg = Debug|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Debug|x64.Build.0 = Debug|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Debug|x86.ActiveCfg = Debug|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Debug|x86.Build.0 = Debug|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Release|Any CPU.Build.0 = Release|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Release|x64.ActiveCfg = Release|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Release|x64.Build.0 = Release|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Release|x86.ActiveCfg = Release|Any CPU
{61016ABA-608B-47FA-9FBD-CA17D24BAB89}.Release|x86.Build.0 = Release|Any CPU
{1EA4392E-960D-4327-9426-4C6220A7B60D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EA4392E-960D-4327-9426-4C6220A7B60D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EA4392E-960D-4327-9426-4C6220A7B60D}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -900,7 +886,6 @@ Global
{46E769E2-FEC7-43EA-99B8-E7A7294D68B2} = {7A71B07F-B28B-4DDA-B1EA-565194056951}
{2BB1527F-D7A1-44BA-A297-4E69A3A4411C} = {7A71B07F-B28B-4DDA-B1EA-565194056951}
{F86D983A-9881-4BE7-AF92-FA0CE41FB319} = {46D66262-FC61-43B9-8E76-A361FA3D6C81}
{61016ABA-608B-47FA-9FBD-CA17D24BAB89} = {46D66262-FC61-43B9-8E76-A361FA3D6C81}
{1EA4392E-960D-4327-9426-4C6220A7B60D} = {7A05C10C-8797-4D29-A97A-F399316BE893}
{0D9C5C7E-F81B-4E0E-B203-22D558E6D7F1} = {B670D679-3B2C-43E8-9F87-5E4E17628011}
{C48DB577-12BB-4AA8-8734-802A39C093BE} = {B670D679-3B2C-43E8-9F87-5E4E17628011}
Expand Down
33 changes: 33 additions & 0 deletions src/Native/GirTestLib/girtest-property-tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ typedef enum
PROP_STRING_VALUE = 1,
PROP_PROPERTY_TESTER = 2,
PROP_TYPED_RECORD_VALUE = 3,
PROP_INT_VALUE = 4,
PROP_BOOLEAN_VALUE = 5,
N_PROPERTIES
} PropertyTesterProperty;

Expand All @@ -22,6 +24,8 @@ struct _GirTestPropertyTester
gchar *string_value;
gchar *property_tester;
GirTestTypedRecordTester* record;
gint int_value;
gboolean boolean_value;
};

G_DEFINE_TYPE(GirTestPropertyTester, girtest_property_tester, G_TYPE_OBJECT)
Expand All @@ -48,6 +52,12 @@ girtest_property_tester_get_property (GObject *object,
case PROP_TYPED_RECORD_VALUE:
g_value_set_boxed (value, self->record);
break;
case PROP_INT_VALUE:
g_value_set_int (value, self->int_value);
break;
case PROP_BOOLEAN_VALUE:
g_value_set_boolean (value, self->boolean_value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
Expand All @@ -72,6 +82,12 @@ girtest_property_tester_set_property (GObject *object,
case PROP_TYPED_RECORD_VALUE:
self->record = g_value_get_boxed (value);
break;
case PROP_INT_VALUE:
self->int_value = g_value_get_int (value);
break;
case PROP_BOOLEAN_VALUE:
self->boolean_value = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
Expand Down Expand Up @@ -111,6 +127,23 @@ girtest_property_tester_class_init(GirTestPropertyTesterClass *class)
properties[PROP_TYPED_RECORD_VALUE] =
g_param_spec_boxed ("record-value", NULL, NULL, GIRTEST_TYPE_TYPED_RECORD_TESTER, G_PARAM_READWRITE);


properties[PROP_INT_VALUE] =
g_param_spec_int ("int-value",
"Integer Value",
"An int value",
G_MININT,
G_MAXINT,
0 /* default value */,
G_PARAM_READWRITE);

properties[PROP_BOOLEAN_VALUE] =
g_param_spec_boolean ("boolean-value",
"Boolean Value",
"A boolean value",
FALSE /* default value */,
G_PARAM_READWRITE);

g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}

Expand Down
18 changes: 0 additions & 18 deletions src/Tests/Libs/GdkPixbuf-2.0.Tests/Assembly.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/Tests/Libs/GdkPixbuf-2.0.Tests/GdkPixbuf-2.0.Tests.csproj

This file was deleted.

48 changes: 0 additions & 48 deletions src/Tests/Libs/GdkPixbuf-2.0.Tests/MemoryManagementTest.cs

This file was deleted.

24 changes: 0 additions & 24 deletions src/Tests/Libs/GdkPixbuf-2.0.Tests/PropertyTest.cs

This file was deleted.

21 changes: 0 additions & 21 deletions src/Tests/Libs/GdkPixbuf-2.0.Tests/Test.cs

This file was deleted.

Binary file removed src/Tests/Libs/GdkPixbuf-2.0.Tests/test.bmp
Binary file not shown.
42 changes: 41 additions & 1 deletion src/Tests/Libs/GirTest-0.1.Tests/ClassTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System;
using System.Runtime.InteropServices;
using FluentAssertions;
using Microsoft.VisualBasic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -60,4 +61,43 @@ public void CanTransferOwnershipOfInterfaces()
instanceData = Marshal.PtrToStructure<GObject.Internal.ObjectData>(executor.Handle);
instanceData.RefCount.Should().Be(1);
}

[TestMethod]
public void TestManualGObjectDisposal()
{
var obj = ClassTester.New();
GObject.Internal.ObjectMapper.ObjectCount.Should().Be(1);
obj.Dispose();
GObject.Internal.ObjectMapper.ObjectCount.Should().Be(0);
}

[TestMethod]
public void TestAutomaticGObjectDisposal()
{
WeakReference weakReference = new(null);
IDisposable? strongReference = null;

CollectAfter(() =>
{
var obj = ClassTester.New();
GObject.Internal.ObjectMapper.ObjectCount.Should().Be(1);
weakReference.Target = obj;
});

GObject.Internal.ObjectMapper.ObjectCount.Should().Be(0);
weakReference.IsAlive.Should().BeFalse();

CollectAfter(() =>
{
var obj = ClassTester.New();

GObject.Internal.ObjectMapper.ObjectCount.Should().Be(1);

strongReference = obj;
weakReference.Target = obj;
});

weakReference.IsAlive.Should().BeTrue();
strongReference.Should().NotBeNull();
}
}
23 changes: 23 additions & 0 deletions src/Tests/Libs/GirTest-0.1.Tests/PropertyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,27 @@ public void SupportsTypedRecordProperty()
PropertyTester.RecordValuePropertyDefinition.UnmanagedName.Should().Be("record-value");
PropertyTester.RecordValuePropertyDefinition.ManagedName.Should().Be(nameof(PropertyTester.RecordValue));
}

[DataTestMethod]
[DataRow(10)]
[DataRow(-10)]
[DataRow(0)]
public void TestIntProperty(int i)
{
var obj = PropertyTester.New();
obj.IntValue = i;

obj.IntValue.Should().Be(i);
}

[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
public void TestBooleanProperty(bool b)
{
var obj = PropertyTester.New();
obj.BooleanValue = b;

obj.BooleanValue.Should().Be(b);
}
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载