2015-08-28 17:55:50 -07:00
/ *
2017-05-21 18:02:53 -07:00
Copyright ( c ) 2017 , Lars Brubaker , John Lewin
2015-08-28 17:55:50 -07:00
All rights reserved .
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice , this
list of conditions and the following disclaimer .
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
and / or other materials provided with the distribution .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES
( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies ,
either expressed or implied , of the FreeBSD Project .
* /
2016-10-25 06:17:37 -07:00
using System.Threading.Tasks ;
2017-03-15 16:17:06 -07:00
using MatterHackers.MatterControl.PartPreviewWindow ;
2015-08-28 17:55:50 -07:00
using NUnit.Framework ;
2022-07-15 17:28:39 -07:00
using TestInvoker ;
2015-08-28 17:55:50 -07:00
2016-05-11 09:13:56 -07:00
namespace MatterHackers.MatterControl.Tests.Automation
2015-08-28 17:55:50 -07:00
{
2022-07-15 17:28:39 -07:00
// Most of these tests are disabled. Local Library and Queue needs to be added by InitializeLibrary() (MatterHackers.MatterControl.ApplicationController).
[TestFixture, Category("MatterControl.UI.Automation"), Parallelizable(ParallelScope.Children)]
2016-10-25 06:17:37 -07:00
public class PrintQueueTests
2015-08-28 17:55:50 -07:00
{
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-05-21 17:10:30 -07:00
public async Task AddOneItemToQueue ( )
2015-09-03 14:52:40 -07:00
{
2017-05-21 17:27:06 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-09-03 14:52:40 -07:00
{
2017-05-21 17:10:30 -07:00
// Expected = initial + 1
int expectedCount = QueueData . Instance . ItemCount + 1 ;
2015-10-27 11:38:12 -07:00
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:10:30 -07:00
testRunner . ChangeToQueueContainer ( ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:10:30 -07:00
// Click Add button and select files
2018-04-07 11:21:02 -07:00
testRunner . InvokeLibraryAddDialog ( ) ;
2017-12-06 15:21:18 -08:00
// Open Fennec_Fox
2018-10-10 13:33:16 -07:00
testRunner . CompleteDialog ( MatterControlUtilities . GetTestItemPath ( "Fennec_Fox.stl" ) ) ;
2015-09-03 14:52:40 -07:00
2017-12-18 22:03:58 -08:00
// Wait for expected outcome
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount ) ;
2015-09-03 14:52:40 -07:00
2017-05-21 17:10:30 -07:00
// Assert - one part added and queue count increases by one
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should increase by 1 when adding 1 item" ) ;
2018-10-10 13:33:16 -07:00
2017-06-14 10:05:39 -07:00
Assert . IsTrue ( testRunner . WaitForName ( "Row Item Fennec_Fox.stl" ) , "Named widget should exist after add(Fennec_Fox)" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-05-21 17:27:06 -07:00
} ) ;
2015-10-27 11:38:12 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-05-21 17:10:30 -07:00
public async Task AddTwoItemsToQueue ( )
2015-10-27 11:38:12 -07:00
{
2017-05-21 17:27:06 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-10-27 11:38:12 -07:00
{
2017-05-21 16:41:10 -07:00
// Expected = initial + 2;
int expectedCount = QueueData . Instance . ItemCount + 2 ;
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 16:29:00 -07:00
testRunner . ChangeToQueueContainer ( ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:10:30 -07:00
// Click Add button and select files
2018-04-07 11:21:02 -07:00
testRunner . InvokeLibraryAddDialog ( ) ;
2017-05-21 16:41:10 -07:00
2017-12-06 15:21:18 -08:00
// Open Fennec_Fox, Batman files
testRunner . CompleteDialog (
string . Format (
2022-07-15 17:28:39 -07:00
"\"{0}\";\"{1}\"" ,
2017-12-06 15:21:18 -08:00
MatterControlUtilities . GetTestItemPath ( "Fennec_Fox.stl" ) ,
MatterControlUtilities . GetTestItemPath ( "Batman.stl" ) ) ,
secondsToWait : 2 ) ;
2015-10-27 11:38:12 -07:00
2017-12-18 22:03:58 -08:00
// Wait for expected outcome
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:10:30 -07:00
// Assert - two parts added and queue count increases by two
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should increase by 2 when adding 2 items" ) ;
2017-06-14 10:05:39 -07:00
Assert . IsTrue ( testRunner . WaitForName ( "Row Item Fennec_Fox.stl" ) , "Named widget should exist after add(Fennec_Fox)" ) ;
Assert . IsTrue ( testRunner . WaitForName ( "Row Item Batman.stl" ) , "Named widget should exist after add(Batman)" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-05-21 17:27:06 -07:00
} ) ;
2015-09-03 14:52:40 -07:00
}
2015-09-04 16:44:41 -07:00
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task RemoveButtonRemovesSingleItem ( )
2015-10-27 11:38:12 -07:00
{
2017-06-06 18:48:46 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-10-27 11:38:12 -07:00
{
2017-06-06 18:48:46 -07:00
int expectedCount = QueueData . Instance . ItemCount - 1 ;
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-27 11:38:12 -07:00
2022-02-17 13:25:43 -08:00
testRunner . NavigateToFolder ( "Queue Row Item Collection" ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:48:46 -07:00
// Select both items
2022-02-07 13:51:49 -08:00
testRunner . SelectListItems ( "Row Item 2013-01-25_Mouthpiece_v2.stl" ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:48:46 -07:00
// Remove item
2017-06-06 18:52:13 -07:00
testRunner . LibraryRemoveSelectedItem ( ) ;
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount , 500 ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:48:46 -07:00
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should decrease by one after clicking Remove" ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:48:46 -07:00
// Make sure selected item was removed
2022-02-07 13:51:49 -08:00
Assert . IsFalse ( testRunner . WaitForName ( "Row Item 2013-01-25_Mouthpiece_v2.stl" , . 5 ) , "Mouthpiece part should *not* exist after remove" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-06 18:48:46 -07:00
} , queueItemFolderToAdd : QueueTemplate . Three_Queue_Items ) ;
2015-10-27 11:38:12 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task RemoveButtonRemovesMultipleItems ( )
2015-10-27 11:38:12 -07:00
{
2017-06-06 18:42:44 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-10-27 11:38:12 -07:00
{
2017-06-06 18:42:44 -07:00
int expectedCount = QueueData . Instance . ItemCount - 2 ;
2015-10-27 11:38:12 -07:00
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-27 11:38:12 -07:00
2022-02-17 13:25:43 -08:00
testRunner . NavigateToFolder ( "Queue Row Item Collection" ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:42:44 -07:00
// Select both items
2022-02-06 08:22:31 -08:00
testRunner . SelectListItems ( "Row Item Batman.stl" , "Row Item 2013-01-25_Mouthpiece_v2.stl" ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:42:44 -07:00
// Remove items
2017-06-06 18:52:13 -07:00
testRunner . LibraryRemoveSelectedItem ( ) ;
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount , 500 ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:42:44 -07:00
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should decrease by two after clicking Remove" ) ;
2015-10-27 11:38:12 -07:00
2017-06-06 18:42:44 -07:00
// Make sure both selected items are removed
2022-02-06 08:22:31 -08:00
Assert . IsFalse ( testRunner . WaitForName ( "Row Item Batman.stl" , . 5 ) , "Batman part should *not* exist after remove" ) ;
Assert . IsFalse ( testRunner . WaitForName ( "Row Item 2013-01-25_Mouthpiece_v2.stl" , . 5 ) , "Mouthpiece part should *not* exist after remove" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-06 18:42:44 -07:00
} , queueItemFolderToAdd : QueueTemplate . Three_Queue_Items ) ;
2016-12-21 17:02:25 -08:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-03-15 16:17:06 -07:00
public async Task DragTo3DViewAddsItem ( )
{
2017-06-05 23:34:33 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2017-03-15 16:17:06 -07:00
{
2022-02-03 17:21:51 -08:00
testRunner . OpenPartTab ( ) ;
2018-04-19 07:58:03 -07:00
2018-11-02 07:35:26 -07:00
testRunner . AddTestAssetsToLibrary ( new [ ] { "Batman.stl" } ) ;
2017-03-15 16:17:06 -07:00
2017-06-05 23:34:33 -07:00
var view3D = testRunner . GetWidgetByName ( "View3DWidget" , out _ ) as View3DWidget ;
2020-09-11 19:59:14 -07:00
var scene = view3D . Object3DControlLayer . Scene ;
2017-03-15 16:17:06 -07:00
2017-09-16 01:11:44 -07:00
Assert . AreEqual ( 0 , scene . Children . Count , "The scene should have zero items before drag/drop" ) ;
2017-03-15 16:17:06 -07:00
2020-09-11 19:59:14 -07:00
testRunner . DragDropByName ( "Row Item Batman" , "Object3DControlLayer" ) ;
2017-09-16 01:11:44 -07:00
Assert . AreEqual ( 1 , scene . Children . Count , "The scene should have one item after drag/drop" ) ;
2017-03-15 16:17:06 -07:00
2018-04-13 17:33:33 -07:00
testRunner . Delay ( . 2 ) ;
2020-09-11 19:59:14 -07:00
testRunner . DragDropByName ( "Row Item Batman" , "Object3DControlLayer" ) ;
2017-09-16 01:11:44 -07:00
Assert . AreEqual ( 2 , scene . Children . Count , "The scene should have two items after drag/drop" ) ;
2017-03-15 16:17:06 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-05 23:34:33 -07:00
} , queueItemFolderToAdd : QueueTemplate . Three_Queue_Items ) ;
2017-03-15 16:17:06 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-05-21 17:27:06 -07:00
public async Task AddAmfFile ( )
2015-10-27 11:38:12 -07:00
{
2017-05-21 17:27:06 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-10-27 11:38:12 -07:00
{
2017-05-21 17:27:06 -07:00
// Expected = initial + 1
int expectedCount = QueueData . Instance . ItemCount + 1 ;
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:27:06 -07:00
testRunner . ChangeToQueueContainer ( ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:27:06 -07:00
// Click Add button and select files
2018-04-07 11:21:02 -07:00
testRunner . InvokeLibraryAddDialog ( ) ;
2015-10-27 11:38:12 -07:00
2017-12-06 15:21:18 -08:00
// Open Rook
testRunner . CompleteDialog (
MatterControlUtilities . GetTestItemPath ( "Rook.amf" ) ) ;
2015-10-29 12:02:22 -07:00
2017-12-18 22:03:58 -08:00
// Wait for expected outcome
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:27:06 -07:00
// Assert - one part added and queue count increases by one
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should increase by 1 when adding 1 item" ) ;
2022-02-04 14:51:41 -08:00
Assert . IsTrue ( testRunner . WaitForName ( "Row Item Rook.amf" ) , "Named widget should exist after add(Rook)" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-05-21 17:27:06 -07:00
} ) ;
2015-10-29 12:02:22 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-05-21 17:37:37 -07:00
public async Task AddStlFile ( )
2015-10-29 12:02:22 -07:00
{
2017-05-21 17:37:37 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-10-29 12:02:22 -07:00
{
2017-05-21 17:37:37 -07:00
// Expected = initial + 1
int expectedCount = QueueData . Instance . ItemCount + 1 ;
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-29 12:02:22 -07:00
2017-05-21 17:37:37 -07:00
testRunner . ChangeToQueueContainer ( ) ;
2015-10-29 12:02:22 -07:00
2017-05-21 17:37:37 -07:00
// Click Add button and select files
2018-04-07 11:21:02 -07:00
testRunner . InvokeLibraryAddDialog ( ) ;
2015-10-29 12:02:22 -07:00
2017-12-06 15:21:18 -08:00
// Open Batman
testRunner . CompleteDialog (
MatterControlUtilities . GetTestItemPath ( "Batman.stl" ) ) ;
2015-10-29 12:02:22 -07:00
2017-12-18 22:03:58 -08:00
// Wait for expected outcome
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount ) ;
2015-10-29 12:02:22 -07:00
2017-05-21 17:37:37 -07:00
// Assert - one part added and queue count increases by one
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should increase by 1 when adding 1 item" ) ;
2017-06-14 10:05:39 -07:00
Assert . IsTrue ( testRunner . WaitForName ( "Row Item Batman.stl" ) , "Named widget should exist after add(Batman)" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-05-21 17:37:37 -07:00
} ) ;
2015-10-29 12:02:22 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-05-21 17:36:09 -07:00
public async Task AddGCodeFile ( )
2015-10-29 12:02:22 -07:00
{
2017-05-21 17:36:09 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2015-10-29 12:02:22 -07:00
{
2017-05-21 17:36:09 -07:00
// Expected = initial + 1
int expectedCount = QueueData . Instance . ItemCount + 1 ;
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2015-10-29 12:02:22 -07:00
2017-05-21 17:36:09 -07:00
testRunner . ChangeToQueueContainer ( ) ;
2015-10-29 12:02:22 -07:00
2017-05-21 17:36:09 -07:00
// Click Add button and select files
2018-04-07 11:21:02 -07:00
testRunner . InvokeLibraryAddDialog ( ) ;
2015-10-29 12:02:22 -07:00
2017-12-06 15:21:18 -08:00
// Open chichen-itza_pyramid
testRunner . CompleteDialog (
MatterControlUtilities . GetTestItemPath ( "chichen-itza_pyramid.gcode" ) ) ;
2015-10-29 12:02:22 -07:00
2017-12-18 22:03:58 -08:00
// Wait for expected outcome
2017-12-15 20:24:58 -08:00
testRunner . WaitFor ( ( ) = > QueueData . Instance . ItemCount = = expectedCount ) ;
2015-10-27 11:38:12 -07:00
2017-05-21 17:36:09 -07:00
// Assert - one part added and queue count increases by one
Assert . AreEqual ( expectedCount , QueueData . Instance . ItemCount , "Queue count should increase by 1 when adding 1 item" ) ;
2017-06-14 10:05:39 -07:00
Assert . IsTrue ( testRunner . WaitForName ( "Row Item chichen-itza_pyramid.gcode" ) , "Named widget should exist after add(chichen-itza)" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-05-21 17:36:09 -07:00
} ) ;
2015-10-27 11:38:12 -07:00
}
}
2015-08-28 17:55:50 -07:00
}