public void OnEyeControllerClick_f() { Debug.Log("click_f"); pianorecorded = TestRecorder.getpianorec(); pianorecorded = false; SceneManager.LoadScene("pianorec"); }
public async Task OnTextBoxDisabled_FloatingHintBackgroundIsOpaque() { await using var recorder = new TestRecorder(App); IVisualElement grid = await LoadXaml(@" <Grid Background=""Red""> <TextBox Style=""{StaticResource MaterialDesignOutlinedTextBox}"" VerticalAlignment=""Top"" Height=""100"" Text=""Some content to force hint to float"" IsEnabled=""false"" Margin=""30"" materialDesign:HintAssist.Hint=""This is a text area""/> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); //textFieldGrid is the element just inside of the border IVisualElement textFieldGrid = await textBox.GetElement("textFieldGrid"); IVisualElement hintBackground = await textBox.GetElement("HintBackgroundBorder"); Color background = await hintBackground.GetEffectiveBackground(textFieldGrid); Assert.Equal(255, background.A); recorder.Success(); }
public async Task OnDatePicker_WithClearButton_ClearsSelectedDate() { await using var recorder = new TestRecorder(App); var stackPanel = await LoadXaml <StackPanel>($@" <StackPanel> <DatePicker SelectedDate=""{DateTime.Today:d}"" materialDesign:TextFieldAssist.HasClearButton=""True""/> </StackPanel>"); var datePicker = await stackPanel.GetElement <DatePicker>("/DatePicker"); var clearButton = await datePicker.GetElement <Button>("PART_ClearButton"); DateTime?selectedDate = await datePicker.GetSelectedDate(); Assert.NotNull(selectedDate); await clearButton.LeftClick(); await Wait.For(async() => { selectedDate = await datePicker.GetSelectedDate(); Assert.Null(selectedDate); }); recorder.Success(); }
public async Task OnTextBox_WithClearButton_ClearsText() { await using var recorder = new TestRecorder(App); var grid = await LoadXaml <Grid>(@" <Grid Margin=""30""> <TextBox VerticalAlignment=""Top"" Text=""Some Text"" materialDesign:TextFieldAssist.HasClearButton=""True""> </TextBox> </Grid>"); var textBox = await grid.GetElement <TextBox>("/TextBox"); var clearButton = await textBox.GetElement <Button>("PART_ClearButton"); string?text = await textBox.GetText(); Assert.NotNull(text); await clearButton.LeftClick(); await Wait.For(async() => { text = await textBox.GetText(); Assert.Null(text); }); recorder.Success(); }
public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday() { await using var recorder = new TestRecorder(App); var stackPanel = await LoadXaml(@" <StackPanel> <materialDesign:TimePicker Language=""en-US"" /> <TextBox /> </StackPanel>"); var timePicker = await stackPanel.GetElement("/TimePicker"); var timePickerTextBox = await timePicker.GetElement("/TimePickerTextBox"); var textBox = await stackPanel.GetElement("/TextBox"); var today = DateTime.Today; await timePickerTextBox.MoveKeyboardFocus(); await timePickerTextBox.SetText("1:23"); await textBox.MoveKeyboardFocus(); var actual = await timePicker.GetSelectedTime(); Assert.Equal(AdjustToday(today, actual).Add(new TimeSpan(1, 23, 0)), actual); recorder.Success(); }
public async Task OnLostFocusIfTimeHasBeenChanged_TextWillbeFormated(string text) { await using var recorder = new TestRecorder(App); var stackPanel = await LoadXaml(@" <StackPanel> <materialDesign:TimePicker/> <TextBox/> </StackPanel>"); var timePicker = await stackPanel.GetElement("/TimePicker"); var timePickerTextBox = await timePicker.GetElement("/TimePickerTextBox"); var textBox = await stackPanel.GetElement("/TextBox"); await timePickerTextBox.MoveKeyboardFocus(); await timePickerTextBox.SendInput($"{text}"); await textBox.MoveKeyboardFocus(); var actual = await timePickerTextBox.GetText(); Assert.Equal("1:02 AM", actual); recorder.Success(); }
public async Task OutlinedButton_BorderCanBeOverridden() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement button = await LoadXaml( @"<Button Content=""Button"" Style=""{StaticResource MaterialDesignOutlinedButton}"" BorderThickness=""5"" BorderBrush=""Red"" />"); Color midColor = await GetThemeColor("PrimaryHueMidBrush"); IVisualElement?internalBorder = await button.GetElement("border"); //Act Thickness borderThickness = await internalBorder.GetProperty <Thickness>(nameof(Border.BorderThickness)); SolidColorBrush borderBrush = await internalBorder.GetProperty <SolidColorBrush>(nameof(Border.BorderBrush)); //Assert Assert.Equal(new Thickness(5), borderThickness); Assert.Equal(Colors.Red, borderBrush.Color); recorder.Success(); }
public async Task HasNoItemsExpanderVisibility_SetOnTreeView_ChangesVisibiliyOnExpanders(Visibility visibility) { await using var recorder = new TestRecorder(App); var treeView = await LoadXaml <TreeView>($@" <TreeView materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""{visibility}""> <TreeViewItem Header=""NoChild"" /> <TreeViewItem Header=""HasChild""> <TreeViewItem Header=""Child"" /> </TreeViewItem> </TreeView>"); var expander = await GetExpanderForHeader("NoChild"); Assert.Equal(visibility, await expander.GetVisibility()); expander = await GetExpanderForHeader("HasChild"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); recorder.Success(); async Task <IVisualElement <ToggleButton> > GetExpanderForHeader(string header) { var item = await treeView !.GetElement(ElementQuery.PropertyExpression <TreeViewItem>(x => x.Header, header)); return(await item.GetElement <ToggleButton>()); } }
public async Task OnTimePickedIfTimeHasNotBeenChanged_TextWillbeFormated(string text) { await using var recorder = new TestRecorder(App); var stackPanel = await LoadXaml(@" <StackPanel> <materialDesign:TimePicker/> </StackPanel>"); var timePicker = await stackPanel.GetElement("/TimePicker"); var timePickerTextBox = await timePicker.GetElement("/TimePickerTextBox"); await timePicker.SetSelectedTime(new DateTime(2020, 8, 10, 1, 2, 0)); await timePickerTextBox.MoveKeyboardFocus(); await timePickerTextBox.SendInput($"{text}"); await timePicker.PickClock(1, 2); var actual = await timePickerTextBox.GetText(); Assert.Equal("1:02 AM", actual); recorder.Success(); }
public async Task OnLostFocusIfSelectedTimeIsNonNull_DatePartDoesNotChange(int year, int month, int day) { await using var recorder = new TestRecorder(App); var stackPanel = await LoadXaml(@" <StackPanel> <materialDesign:TimePicker Language=""en-US"" /> <TextBox /> </StackPanel>"); var timePicker = await stackPanel.GetElement("/TimePicker"); var timePickerTextBox = await timePicker.GetElement("/TimePickerTextBox"); var textBox = await stackPanel.GetElement("/TextBox"); await timePicker.SetSelectedTime(new DateTime(year, month, day)); await timePickerTextBox.MoveKeyboardFocus(); await timePickerTextBox.SetText("1:10"); await textBox.MoveKeyboardFocus(); var actual = await timePicker.GetSelectedTime(); Assert.Equal(new DateTime(year, month, day, 1, 10, 0), actual); recorder.Success(); }
public async Task OutlinedButton_OnMouseOver_UsesThemeBrush() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement button = await LoadXaml( @"<Button Content=""Button"" Style=""{StaticResource MaterialDesignOutlinedButton}""/>"); Color midColor = await GetThemeColor("PrimaryHueMidBrush"); IVisualElement?internalBorder = await button.GetElement("border"); //Act await button.MoveCursorToElement(Position.Center); await Wait.For(async() => { SolidColorBrush internalBorderBackground = await internalBorder.GetProperty <SolidColorBrush>(nameof(Border.Background)); //Assert Assert.Equal(midColor, internalBorderBackground.Color); }); recorder.Success(); }
public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste() { await using var recorder = new TestRecorder(App); var comboBox = await LoadXaml <ComboBox>(@" <ComboBox IsEditable=""True"" Width=""200"" Style=""{StaticResource MaterialDesignComboBox}""> <ComboBoxItem Content=""Select1"" /> <ComboBoxItem>Select2</ComboBoxItem> <ComboBoxItem>Select3</ComboBoxItem> <ComboBoxItem>Select4</ComboBoxItem> <ComboBoxItem>Select5</ComboBoxItem> </ComboBox>"); await comboBox.RightClick(); IVisualElement <ContextMenu>?contextMenu = await comboBox.GetContextMenu(); Assert.True(contextMenu is not null, "No context menu set on the ComboBox"); await AssertMenu("Cut"); await AssertMenu("Copy"); await AssertMenu("Paste"); recorder.Success(); async Task AssertMenu(string menuHeader) { var menuItem = await contextMenu !.GetElement(ElementQuery.PropertyExpression <MenuItem>(x => x.Header, menuHeader)); Assert.True(menuItem is not null, $"{menuHeader} menu item not found"); } }
public async Task OnPasswordBox_WithClearButton_ClearsPassword() { await using var recorder = new TestRecorder(App); var grid = await LoadXaml <Grid>(@" <Grid Margin=""30""> <PasswordBox materialDesign:TextFieldAssist.HasClearButton=""True"" /> </Grid>"); var passwordBox = await grid.GetElement <PasswordBox>("/PasswordBox"); var clearButton = await passwordBox.GetElement <Button>("PART_ClearButton"); await passwordBox.SendKeyboardInput($"Test"); string?password = await passwordBox.GetPassword(); Assert.NotNull(password); await clearButton.LeftClick(); await Wait.For(async() => { password = await passwordBox.GetPassword(); Assert.Null(password); }); recorder.Success(); }
public async Task OnTextCleared_MultilineTextBox() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement grid = await LoadXaml(@" <Grid> <TextBox Style=""{StaticResource MaterialDesignFilledTextBox}"" materialDesign:HintAssist.Hint=""Floating hint in a box"" VerticalAlignment=""Top""/> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); Rect initialRect = await textBox.GetCoordinates(); double initialHeight = await textBox.GetActualHeight(); await textBox.SetText($"Line 1{Environment.NewLine}Line 2"); double twoLineHeight = await textBox.GetActualHeight(); //Act await textBox.SetText(""); //Assert await Wait.For(async() => Assert.Equal(initialHeight, await textBox.GetActualHeight())); Rect rect = await textBox.GetCoordinates(); Assert.Equal(initialRect, rect); recorder.Success(); }
public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.TraceInformation("TestRequestSubmitter entry point called", "Information"); var tps = int.Parse(CloudConfigurationManager.GetSetting("TPS")); var totalTransactions = int.Parse(CloudConfigurationManager.GetSetting("TotalTransactions")); string instanceId = RoleEnvironment.CurrentRoleInstance.Id; string storageConnectionString = CloudConfigurationManager.GetSetting("StorageConnectionString"); var serviceUri = new Uri(CloudConfigurationManager.GetSetting("ServiceUri")); Task webApiSubmitterTask = TestWebApiSubmitter.StartRequestSubmitterAsync(serviceUri, storageConnectionString, instanceId + "-WebApi", tps, totalTransactions); string requestQueueName = CloudConfigurationManager.GetSetting("ServiceRequestQueue"); string responseQueueName = "response-queue-" + instanceId.ToLowerInvariant().Replace('_', '-'); Task queueSubmitterTask = TestServiceQueueSubmitter.StartRequestSubmitterAsync(storageConnectionString, requestQueueName, responseQueueName, tps, totalTransactions); try { Task.WhenAny(queueSubmitterTask, webApiSubmitterTask).Wait(); } catch (Exception exception) { TestRecorder.LogException(storageConnectionString, instanceId, exception); throw; } }
public static void Run(TestContext context, Action <ConsoleApp> testCode, [CallerMemberName] string testName = null, int w = 80, int h = 30) { ConsoleApp app = new ConsoleApp(w, h); app.Recorder = TestRecorder.CreateTestRecorder(testName, context); app.InvokeNextCycle(() => { testCode(app); }); app.Start().Wait(); }
protected override void OnAttached(InputRecorder inputRecorder) { Assert.IsTrue(inputRecorder.FrameDataRecorder is FrameInputData); var frameInputData = inputRecorder.FrameDataRecorder as FrameInputData; TestRecorder.RegistToFrameInputData(); frameInputData.AddChildRecorder(CreateInputData()); }
// Start is called before the first frame update void Start() { pianorecorded = TestRecorder.getpianorec(); guitarrecorded = TestRecorder.getguitarrec(); bassrecorded = TestRecorder.getbassrec(); drumsrecorded = TestRecorder.getdrumsrec(); micrecorded = TestRecorder.getmicrec(); finishscene(); }
public async Task OnRegisterSerializer_RegistersCustomSerializer() { await using var recorder = new TestRecorder(App); await App.RegisterSerializer <CustomSerializer>(); Assert.AreEqual("In-Test Window Title-Out", await Window.GetTitle()); recorder.Success(); }
public async Task DrawerHost_CancelingClosingEvent_DrawerStaysOpen() { await using var recorder = new TestRecorder(App); IVisualElement <DrawerHost> drawerHost = (await LoadUserControl <CancellingDrawerHost>()).As <DrawerHost>(); var showButton = await drawerHost.GetElement <Button>("ShowButton"); var closeButton = await drawerHost.GetElement <Button>("CloseButton"); var closeButtonDp = await drawerHost.GetElement <Button>("CloseButtonDp"); var openedEvent = await drawerHost.RegisterForEvent(nameof(DrawerHost.DrawerOpened)); await showButton.LeftClick(); //Allow open animation to finish await Task.Delay(300); await Wait.For(async() => (await openedEvent.GetInvocations()).Count == 1); var closingEvent = await drawerHost.RegisterForEvent(nameof(DrawerHost.DrawerClosing)); //Attempt closing with routed command await closeButton.LeftClick(); await Task.Delay(100); await Wait.For(async() => (await closingEvent.GetInvocations()).Count == 1); Assert.True(await drawerHost.GetIsLeftDrawerOpen()); //Attempt closing with click away await drawerHost.LeftClick(); await Task.Delay(100); await Wait.For(async() => (await closingEvent.GetInvocations()).Count == 2); Assert.True(await drawerHost.GetIsLeftDrawerOpen()); //Attempt closing with DP property toggle await closeButtonDp.LeftClick(); await Task.Delay(100); await Wait.For(async() => (await closingEvent.GetInvocations()).Count == 3); Assert.True(await drawerHost.GetIsLeftDrawerOpen()); recorder.Success(); }
public async Task OnOpenDialog_OverlayCoversContent() { await using var recorder = new TestRecorder(App); IVisualElement dialogHost = await LoadUserControl <WithCounter>(); var overlay = await dialogHost.GetElement <Grid>("PART_ContentCoverGrid"); var resultTextBlock = await dialogHost.GetElement <TextBlock>("ResultTextBlock"); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 0"); var testOverlayButton = await dialogHost.GetElement <Button>("TestOverlayButton"); await testOverlayButton.LeftClick(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); var showDialogButton = await dialogHost.GetElement <Button>("ShowDialogButton"); await showDialogButton.LeftClick(); var closeDialogButton = await dialogHost.GetElement <Button>("CloseDialogButton"); await Wait.For(async() => await closeDialogButton.GetIsVisible() == true); await testOverlayButton.LeftClick(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); await Task.Delay(200); await closeDialogButton.LeftClick(); var retry = new Retry(5, TimeSpan.FromSeconds(5)); try { await Wait.For(async() => await overlay.GetVisibility() != Visibility.Visible, retry); } catch (TimeoutException) { await closeDialogButton.LeftClick(); await Wait.For(async() => await overlay.GetVisibility() != Visibility.Visible, retry); } await testOverlayButton.LeftClick(); await Wait.For(async() => Assert.Equal("Clicks: 2", await resultTextBlock.GetText()), retry); recorder.Success(); }
public void When_30_Sec_Add_0_Minute_Remains_Unchanged() { var recorder = new TestRecorder(30); var speedProgress = new Mock <ISpeedProgress>(); var practiceTimeProgress = new Mock <IPracticeTimeProgress>(); var manualProgress = new Mock <IManualProgress>(); using (var exerciseRecorder = new ExerciseRecorder(recorder, 1, "Exercise Title", speedProgress.Object, practiceTimeProgress.Object, manualProgress.Object)) { exerciseRecorder.AddMinutes(0); Assert.AreEqual(30, exerciseRecorder.RecordedSeconds); } }
public void When_Added_And_SecondsAreFraction_Removes_Fraction_InIncrement() { var recorder = new TestRecorder(110.3); var speedProgress = new Mock <ISpeedProgress>(); var practiceTimeProgress = new Mock <IPracticeTimeProgress>(); var manualProgress = new Mock <IManualProgress>(); using (var exerciseRecorder = new ExerciseRecorder(recorder, 1, "Exercise Title", speedProgress.Object, practiceTimeProgress.Object, manualProgress.Object)) { exerciseRecorder.AddMinutes(2); Assert.AreEqual(180, exerciseRecorder.RecordedSeconds); } }
public void When_30_Sec_Add_Minute_Goes_To_Next_Exact_Minute() { var recorder = new TestRecorder(30); var speedProgress = new Mock <ISpeedProgress>(); var practiceTimeProgress = new Mock <IPracticeTimeProgress>(); var manualProgress = new Mock <IManualProgress>(); using (var exerciseRecorder = new ExerciseRecorder(recorder, 1, "Exercise Title", speedProgress.Object, practiceTimeProgress.Object, manualProgress.Object)) { exerciseRecorder.AddMinutes(1); Assert.AreEqual(60, exerciseRecorder.RecordedSeconds); } }
public async Task SaveScreenshot_WithSuffix_SavesImage() { var app = new Simulators.App(); var testRecorder = new TestRecorder(app); await testRecorder.SaveScreenshot("MySuffix"); var file = GetScreenshots().Single(); var fileName = Path.GetFileName(file); Assert.AreEqual($"{nameof(SaveScreenshot_WithSuffix_SavesImage)}MySuffix{GetLineNumber(-5)}-win1.jpg", fileName); }
public void When_Is_5Min40sec_Subtract_3Min_Minute_Is_3_Minutes() { var recorder = new TestRecorder(340); var speedProgress = new Mock <ISpeedProgress>(); var practiceTimeProgress = new Mock <IPracticeTimeProgress>(); var manualProgress = new Mock <IManualProgress>(); using (var exerciseRecorder = new ExerciseRecorder(recorder, 1, "Exercise Title", speedProgress.Object, practiceTimeProgress.Object, manualProgress.Object)) { exerciseRecorder.SubtractMinutes(3); Assert.AreEqual(180, exerciseRecorder.RecordedSeconds); } }
public async Task OnGetMainWindow_ReturnsNullBeforeWindowCreated() { await using var app = App.StartRemote(); await using var recorder = new TestRecorder(app); await app.InitializeWithDefaults(Assembly.GetExecutingAssembly().Location); IWindow?mainWindow = await app.GetMainWindow(); Assert.IsNull(mainWindow); recorder.Success(); }
public async Task OnCreateWindow_CanUseCustomWindow() { await using var app = App.StartRemote(); await using var recorder = new TestRecorder(app); await app.InitializeWithDefaults(Assembly.GetExecutingAssembly().Location); IWindow window = await app.CreateWindow <TestWindow>(); Assert.AreEqual("Custom Test Window", await window.GetTitle()); recorder.Success(); }
public async Task OnCreateWindow_CanReadTitle() { await using var app = App.StartRemote(); await using var recorder = new TestRecorder(app); await app.InitializeWithDefaults(Assembly.GetExecutingAssembly().Location); IWindow window = await app.CreateWindowWithContent("", title : "Test Window Title"); Assert.AreEqual("Test Window Title", await window.GetTitle()); recorder.Success(); }
public async Task FontSettingsSholdInheritIntoDialog() { await using var recorder = new TestRecorder(App); IVisualElement grid = await LoadXaml <Grid>(@" <Grid TextElement.FontSize=""42"" TextElement.FontFamily=""Times New Roman"" TextElement.FontWeight=""ExtraBold""> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <materialDesign:DialogHost> <materialDesign:DialogHost.DialogContent> <TextBlock Text=""Some Text"" x:Name=""TextBlock1"" /> </materialDesign:DialogHost.DialogContent> <Button Content=""Show Dialog"" x:Name=""ShowButton1"" Command=""{x:Static materialDesign:DialogHost.OpenDialogCommand}"" /> </materialDesign:DialogHost> <materialDesign:DialogHost Style=""{StaticResource MaterialDesignEmbeddedDialogHost}"" Grid.Column=""1""> <materialDesign:DialogHost.DialogContent> <TextBlock Text=""Some Text"" x:Name=""TextBlock2"" /> </materialDesign:DialogHost.DialogContent> <Button Content=""Show Dialog"" x:Name=""ShowButton2"" Command=""{x:Static materialDesign:DialogHost.OpenDialogCommand}"" /> </materialDesign:DialogHost> </Grid>"); var showButton1 = await grid.GetElement <Button>("ShowButton1"); var showButton2 = await grid.GetElement <Button>("ShowButton2"); await showButton1.LeftClick(); await showButton2.LeftClick(); await Task.Delay(300); var text1 = await grid.GetElement <TextBlock>("TextBlock1"); var text2 = await grid.GetElement <TextBlock>("TextBlock2"); Assert.Equal(42, await text1.GetFontSize()); Assert.True((await text1.GetFontFamily())?.FamilyNames.Values.Contains("Times New Roman")); Assert.Equal(FontWeights.ExtraBold, await text1.GetFontWeight()); Assert.Equal(42, await text2.GetFontSize()); Assert.True((await text2.GetFontFamily())?.FamilyNames.Values.Contains("Times New Roman")); Assert.Equal(FontWeights.ExtraBold, await text2.GetFontWeight()); recorder.Success(); }
public RecorderTester(List<int> Numbers) { this.Numbers = Numbers; m_recorder = new TestRecorder(this); }