Skip to content

Commit 6246f58

Browse files
authored
Merge pull request #68 from SourcePointUSA/DIA-4029-ProgrammaticCustomConsentGDPR-ui-test
[DIA-4029] Add UI test for `customConsentGDPR` feature
2 parents e5fe026 + 422058d commit 6246f58

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

Assets/ConsentManagementProvider/Scripts/facade/CMPTestUtils.cs

+24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace ConsentManagementProvider
44
{
55
public static class CMPTestUtils
66
{
7+
static bool delegateCalled = false;
78
public static void LoadPrivacyManager(
89
string campaignType,
910
string pmId)
@@ -13,5 +14,28 @@ public static void LoadPrivacyManager(
1314
campaignType: type,
1415
pmId: pmId);
1516
}
17+
18+
public static void CustomConsentGDPR(string arg)
19+
{
20+
string[] vendors = { "5fbe6f050d88c7d28d765d47", "5ff4d000a228633ac048be41" };
21+
string[] categories = { "60657acc9c97c400122f21f3", "608bad95d08d3112188e0e36", "608bad95d08d3112188e0e2f" };
22+
string[] legIntCategories = { };
23+
delegateCalled = false;
24+
CMP.ConcreteInstance.CustomConsentGDPR(vendors, categories, legIntCategories, onSuccessDelegate);
25+
}
26+
27+
public static void DeleteCustomConsentGDPR(string arg)
28+
{
29+
string[] vendors = { "5fbe6f050d88c7d28d765d47", "5ff4d000a228633ac048be41" };
30+
string[] categories = { "60657acc9c97c400122f21f3", "608bad95d08d3112188e0e36", "608bad95d08d3112188e0e2f" };
31+
string[] legIntCategories = { };
32+
delegateCalled = false;
33+
CMP.ConcreteInstance.DeleteCustomConsentGDPR(vendors, categories, legIntCategories, onSuccessDelegate);
34+
}
35+
36+
private static void onSuccessDelegate(GdprConsent customConsent)
37+
{
38+
delegateCalled = true;
39+
}
1640
}
1741
}

UI-TESTS/UITests.cs

+34
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,40 @@ public void ProgramaticRejectAllUSNATTest()
508508
Assert.That(status=="rejected", Is.True);
509509
}
510510

511+
[Test]
512+
public void ProgramaticCustomConsentGDPRTest()
513+
{
514+
Console.WriteLine(">>>ProgramaticCustomConsentGDPRTest");
515+
if (driver == null)
516+
{
517+
Assert.Fail("Driver has not been initialized.");
518+
}
519+
520+
string firstLayerContext = pages.preFirstLayer.SelectFirstLayer();
521+
522+
pages.firstLayerGO(true, true, true);
523+
pages.nativeAppLayer.waitForSdkDone();
524+
525+
Console.WriteLine("Call 'CustomConsentGDPR'");
526+
altDriver.CallStaticMethod<object>("ConsentManagementProvider.CMPTestUtils", "CustomConsentGDPR", "Assembly-CSharp", new[] { "" });
527+
System.Threading.Thread.Sleep(2000);
528+
Console.WriteLine($"Try to get: delegateCalled");
529+
bool delegateCalled = altDriver.GetStaticProperty<bool>("ConsentManagementProvider.CMPTestUtils", "delegateCalled", "Assembly-CSharp");
530+
Console.WriteLine($"delegateCalled: {delegateCalled}");
531+
532+
Assert.That(delegateCalled, Is.True);
533+
534+
Console.WriteLine("Call 'DeleteCustomConsentGDPR'");
535+
altDriver.CallStaticMethod<object>("ConsentManagementProvider.CMPTestUtils", "DeleteCustomConsentGDPR", "Assembly-CSharp", new[] { "" });
536+
System.Threading.Thread.Sleep(2000);
537+
Console.WriteLine($"Try to get: delegateCalled");
538+
delegateCalled = altDriver.GetStaticProperty<bool>("ConsentManagementProvider.CMPTestUtils", "delegateCalled", "Assembly-CSharp");
539+
Console.WriteLine($"delegateCalled: {delegateCalled}");
540+
541+
Assert.That(delegateCalled, Is.True);
542+
}
543+
544+
511545
[TearDown]
512546
public void Teardown()
513547
{

UI-TESTS/startup.sh

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ sleep 5
5757
runTest android.runsettings ProgramaticRejectAllCCPATest
5858
sleep 5
5959
runTest android.runsettings ProgramaticRejectAllUSNATTest
60+
sleep 5
61+
runTest android.runsettings ProgramaticCustomConsentGDPRTest
6062

6163
#Kill android emulator
6264
osascript -e 'tell app "Terminal" to close window id '${androidEmulator_window_id}''
@@ -86,6 +88,8 @@ sleep 5
8688
runTest ios.runsettings ProgramaticRejectAllCCPATest
8789
sleep 5
8890
runTest ios.runsettings ProgramaticRejectAllUSNATTest
91+
sleep 5
92+
runTest ios.runsettings ProgramaticCustomConsentGDPRTest
8993

9094
#Kill ios emulator
9195
osascript -e 'tell app "Terminal" to close window id '${iosEmulator_window_id}''

0 commit comments

Comments
 (0)