From d00d14034d403199fcf3873e7a3b68ba332bebbe Mon Sep 17 00:00:00 2001 From: raycad Date: Fri, 22 Jun 2018 17:18:38 +0700 Subject: [PATCH] [Non-ACR][ManualTemplate][Fix issues when using ConfirmFail] Change-Id: I7427ff341c10a672066649d91550ef6117bda8f0 Signed-off-by: raycad --- tct-suite-vs/Template/ManualTemplate/Utils.cs | 27 +++++++++++++++++----- .../Template/ManualTemplateForWearable/Utils.cs | 27 ++++++++++++++++------ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/tct-suite-vs/Template/ManualTemplate/Utils.cs b/tct-suite-vs/Template/ManualTemplate/Utils.cs index 9741edc..e382e6d 100755 --- a/tct-suite-vs/Template/ManualTemplate/Utils.cs +++ b/tct-suite-vs/Template/ManualTemplate/Utils.cs @@ -246,9 +246,12 @@ namespace NUnit.Framework public class ManualTest { private static bool Confirmed = true; + private static int _type = 0; + private static string _messageFail = ""; public static async Task WaitForConfirm() { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Wait for confirm result ..."); if (IsWearable()) @@ -257,13 +260,23 @@ namespace NUnit.Framework } else { + _messageFail = ""; Confirmed = false; TestPage.GetInstance().UnlockUIButton(); while (true) { await Task.Delay(200); - if (Confirmed) + if (Confirmed && _type == 1) + { + _type = 0; + break; + } + else if (_type == 2) + { + _type = 0; + Assert.Fail(_messageFail); break; + } } } } @@ -294,21 +307,23 @@ namespace NUnit.Framework LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "[Common] Confirm()"); Confirmed = true; + _type = 1; } } - public static async Task ConfirmFail(String message) + public static void ConfirmFail(String message) { if (IsWearable()) { - await WearableTemplate.ManualTest.ConfirmFail(message); + WearableTemplate.ManualTest.ConfirmFail(message); } else { LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "[Common] ConfirmFail(String message)"); - TestPage.GetInstance().UnlockUIButton(); - await Task.Delay(2000); - Assert.Fail(message); + + Confirmed = true; + _type = 2; + _messageFail = message; } } diff --git a/tct-suite-vs/Template/ManualTemplateForWearable/Utils.cs b/tct-suite-vs/Template/ManualTemplateForWearable/Utils.cs index c4a152f..136e7d6 100755 --- a/tct-suite-vs/Template/ManualTemplateForWearable/Utils.cs +++ b/tct-suite-vs/Template/ManualTemplateForWearable/Utils.cs @@ -246,16 +246,28 @@ namespace WearableTemplate public class ManualTest { private static bool Confirmed = true; + private static int _type = 0; + private static string _messageFail = ""; public static async Task WaitForConfirm() { + _messageFail = ""; Confirmed = false; TestPage.GetInstance().UnlockUIButton(); while (true) { await Task.Delay(200); - if (Confirmed) + if (Confirmed && _type == 1) + { + _type = 0; + break; + } + else if (_type == 2) + { + _type = 0; + Assert.Fail(_messageFail); break; + } } } @@ -267,13 +279,14 @@ namespace WearableTemplate public static void Confirm() { Confirmed = true; + _type = 1; } - public static async Task ConfirmFail(String message) + public static void ConfirmFail(String message) { - TestPage.GetInstance().UnlockUIButton(); - await Task.Delay(2000); - Assert.Fail(message); + Confirmed = true; + _type = 2; + _messageFail = message; } public static void DisplayLabel(String msg) @@ -285,7 +298,7 @@ namespace WearableTemplate HorizontalOptions = LayoutOptions.CenterAndExpand, Text = msg + " is not support on this profile. So, you can not test this TC. please mark as PASS", TextColor = global::Xamarin.Forms.Color.FromHex("#1E90FF"), - FontSize=4, + FontSize = 4, }; var layout = new StackLayout() @@ -310,7 +323,7 @@ namespace WearableTemplate { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, - Text = msg , + Text = msg, TextColor = global::Xamarin.Forms.Color.FromHex("#1E90FF"), FontSize = 4, }; -- 2.7.4