public void ItemInfoBinding()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService taskbarService  = taskbarServiceImpl;
            ImageSource           icon_1          = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ThumbButtonInfo       thumbButtonInfo = new ThumbButtonInfo()
            {
                Description = "thumbButton51"
            };

            RealWindow.TaskbarItemInfo.ProgressValue = 0.5;
            RealWindow.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error;
            RealWindow.TaskbarItemInfo.Overlay       = icon_1;
            RealWindow.TaskbarItemInfo.Description   = "test1";
            RealWindow.TaskbarItemInfo.ThumbButtonInfos.Add(thumbButtonInfo);
            RealWindow.TaskbarItemInfo.ThumbnailClipMargin = new Thickness {
                Bottom = 1, Left = 50, Right = 99, Top = 11
            };
            Assert.AreEqual(0.5, taskbarService.ProgressValue);
            Assert.AreEqual(TaskbarItemProgressState.Error, taskbarService.ProgressState);
            Assert.AreEqual(icon_1, taskbarService.OverlayIcon);
            Assert.AreEqual("test1", taskbarService.Description);
            AssertHelper.AssertEnumerablesAreEqual(new TaskbarThumbButtonInfo[] {
                new TaskbarThumbButtonInfo()
                {
                    Description = "thumbButton51"
                }
            }, taskbarService.ThumbButtonInfos, true, new string[] { "ItemInfo" });
            Assert.AreEqual(new Thickness {
                Bottom = 1, Left = 50, Right = 99, Top = 11
            }, taskbarService.ThumbnailClipMargin);
        }
        public void SetThumbButtonInfos()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ITaskbarButtonService  taskbarService    = taskbarServiceImpl;
            TaskbarThumbButtonInfo thumbButtonInfo_1 = new TaskbarThumbButtonInfo()
            {
                Description = "thumbButton1"
            };
            TaskbarThumbButtonInfo thumbButtonInfo_2 = new TaskbarThumbButtonInfo()
            {
                Description = "thumbButton2"
            };

            taskbarService.ThumbButtonInfos.Add(thumbButtonInfo_1);
            taskbarService.ThumbButtonInfos.Add(thumbButtonInfo_2);
            AssertHelper.AssertEnumerablesAreEqual(new ThumbButtonInfo[] {
                new ThumbButtonInfo()
                {
                    Description = "thumbButton1"
                },
                new ThumbButtonInfo()
                {
                    Description = "thumbButton2"
                },
            }, RealWindow.TaskbarItemInfo.ThumbButtonInfos, true, new string[] { "Command" });
        }
        public void RejectedReasons()
        {
            ImageSource invalidIcon = new BitmapImage()
            {
                UriSource = AssemblyHelper.GetResourceUri(typeof(ApplicationJumpListServiceTests).Assembly, "INVALID")
            };
            ImageSource icon = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(
                AssemblyHelper.GetResourceUri(typeof(ApplicationJumpListServiceTests).Assembly, "Services/ApplicationJumpListService/demoicon.ico"));

            applicationJumpListService.Items.Add("a:None");
            applicationJumpListService.Items.Add("b:InvalidItem");
            applicationJumpListService.Items.Add("c:NoRegisteredHandler");
            applicationJumpListService.Items.Add("d:RemovedByUser");
            AssertHelper.AssertThrows <ArgumentException>(() => {
                applicationJumpListService.Items.Add("e", invalidIcon, () => { }, "e");
            }, e => {
                Assert.AreEqual("icon", e.ParamName);
                Assert.IsTrue(e.InnerException is ApplicationJumpTaskInvalidIconException);
            });
            AssertHelper.AssertThrows <ApplicationJumpTaskBothIconAndIconResourcePathSpecifiedException>(() => {
                applicationJumpListService.Items.Add(new ApplicationJumpTaskInfo()
                {
                    Title = "g", Icon = icon, IconResourcePath = "C:\\1.ico", Action = () => { }, CommandId = "g"
                });
            });
            IEnumerable <RejectedApplicationJumpItem> rejection = applicationJumpListService.Apply();

            AssertHelper.AssertEnumerablesAreEqual(new JumpItemRejectionReason[] {
                JumpItemRejectionReason.None,
                JumpItemRejectionReason.InvalidItem,
                JumpItemRejectionReason.NoRegisteredHandler,
                JumpItemRejectionReason.RemovedByUser,
            }, rejection.Select(r => r.Reason));
        }
 public void ClearJumpPath()
 {
     applicationJumpListService.Items.Add("1");
     applicationJumpListService.Items.Add("category", "2");
     applicationJumpListService.Items.Clear();
     applicationJumpListService.Apply();
     AssertHelper.AssertEnumerablesAreEqual(new JumpItem[] { }, nativeJumpList.AppliedList.JumpItems, true, false);
 }
Beispiel #5
0
        public void EnumerableConverter_ConvertToEnumerableTest()
        {
            var converter = new EnumerableConverter()
            {
                TargetItemType = typeof(string), ItemConverter = new ToStringConverter()
            };

            Assert.AreEqual(null, converter.Convert(null, null, null, null));
            AssertHelper.AssertEnumerablesAreEqual(new string[] { }, converter.Convert(Enumerable.Empty <int>(), null, null, null).With(x => (IEnumerable <string>)x).With(x => x.ToArray()));
            AssertHelper.AssertEnumerablesAreEqual(new string[] { "0", "1", "2" }, (IEnumerable <string>)converter.Convert(new int[] { 0, 1, 2 }, null, null, null));
        }
        public void AttachServiceToWindowWithTaskbarButtonInfo()
        {
            ImageSource icon_1 = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ImageSource icon_2 = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon2.png"));

            RealWindow.TaskbarItemInfo = new TaskbarItemInfo()
            {
                ProgressState    = TaskbarItemProgressState.Paused,
                ProgressValue    = 0.1,
                Description      = "desc",
                Overlay          = icon_1,
                ThumbButtonInfos = new ThumbButtonInfoCollection {
                    new ThumbButtonInfo()
                    {
                        Description = "thumbButton1"
                    }
                },
                ThumbnailClipMargin = new Thickness {
                    Left = 100, Top = 105, Right = 130, Bottom = 110
                }
            };
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService()
            {
                ProgressState    = TaskbarItemProgressState.Error,
                ProgressValue    = 0.2,
                Description      = "desc2",
                OverlayIcon      = icon_2,
                ThumbButtonInfos = new TaskbarThumbButtonInfoCollection {
                    new TaskbarThumbButtonInfo()
                    {
                        Description = "thumbButton2"
                    }
                },
                ThumbnailClipMargin = new Thickness {
                    Left = 50, Top = 555, Right = 135, Bottom = 90
                }
            };

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            Assert.AreEqual(TaskbarItemProgressState.Error, RealWindow.TaskbarItemInfo.ProgressState);
            Assert.AreEqual(0.2, RealWindow.TaskbarItemInfo.ProgressValue);
            Assert.AreEqual("desc2", RealWindow.TaskbarItemInfo.Description);
            AssertHelper.AssertEnumerablesAreEqual(new ThumbButtonInfo[] {
                new ThumbButtonInfo()
                {
                    Description = "thumbButton2"
                },
            }, RealWindow.TaskbarItemInfo.ThumbButtonInfos, true, new string[] { "Command" });

            Assert.AreEqual(new Thickness {
                Left = 50, Top = 555, Right = 135, Bottom = 90
            }, RealWindow.TaskbarItemInfo.ThumbnailClipMargin);
        }
        public void SyncWithSimpleList()
        {
            List <int> list = new List <int>()
            {
                0, 1, 2
            };
            ObservableCollection <int> targetCollection = new ObservableCollection <int>();

            CreateAndCheckBinding(() => CollectionBindingHelper.Bind(targetCollection, i => i, list, i => i));
            AssertHelper.AssertEnumerablesAreEqual(list, targetCollection);
        }
        public void AddApplicationJumpTaskTwice()
        {
            applicationJumpListService.Items.Add("category", "1", null, "desc", () => { });
            AssertHelper.AssertThrows <InvalidOperationException>(() => {
                applicationJumpListService.Items.Add("category", "1", null, "desc", () => { });
            });
            applicationJumpListService.Items.Add("another category", "1", null, "desc", () => { });
            IEnumerable <RejectedApplicationJumpItem> rejection = applicationJumpListService.Apply();

            AssertHelper.AssertEnumerablesAreEqual(new JumpItemRejectionReason[] { }, rejection.Select(r => r.Reason));
        }
        public void SyncWithSimpleList()
        {
            List <int> list = new List <int>()
            {
                0, 1, 2
            };
            ObservableCollection <int> targetCollection = new ObservableCollection <int>();

            SyncCollectionHelper.TwoWayBind(targetCollection, list, i => i, i => i);
            AssertHelper.AssertEnumerablesAreEqual(list, targetCollection);
        }
        public void AddApplicationJumpTask()
        {
            Action action = () => { };
            ApplicationJumpTaskInfo jumpTask = applicationJumpListService.Items.Add("category", "1", null, "desc", action);

            applicationJumpListService.Apply();
            AssertHelper.AssertEnumerablesAreEqual(
                new ApplicationJumpTaskInfo[] {
                jumpTask
            }, jumpActionsManager.RegisteredActions, true
                );
        }
        public void MoveItemForward_CompareCollections()
        {
            ObservableCollection <int> collection1 = new ObservableCollection <int>()
            {
                0, 1, 2, 3, 4, 5
            };
            ObservableCollection <int> collection2 = new ObservableCollection <int>();

            CreateAndCheckBinding(() => CollectionBindingHelper.Bind(collection2, x => x, collection1, x => x));
            AssertHelper.AssertEnumerablesAreEqual(collection1, collection2);
            collection1.Move(1, 3);
            AssertHelper.AssertEnumerablesAreEqual(collection1, collection2);
        }
 public void FillJumpListInXaml_AttachToWindow_ShowWindow_CheckApplied()
 {
     applicationJumpListServiceInstance.Items.Add(new ApplicationJumpPath()
     {
         Path = "1.txt"
     });
     Interaction.GetBehaviors(Window).Add((ServiceBase)applicationJumpListService);
     EnqueueShowWindow();
     Assert.IsTrue(Window.IsLoaded);
     AssertHelper.AssertEnumerablesAreEqual(new JumpItem[] { new JumpPath()
                                                             {
                                                                 Path = "1.txt"
                                                             } }, nativeJumpList.AppliedList.JumpItems, true, false);
 }
        public void AddApplicationJumpTaskWithIcon_CheckIconJumpTaskIconResourcePath()
        {
            ImageSource icon = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(
                AssemblyHelper.GetResourceUri(typeof(ApplicationJumpListServiceTests).Assembly, "Services/ApplicationJumpListService/demoicon.ico"));
            ApplicationJumpTaskInfo applicationJumpTask = applicationJumpListService.Items.Add("title", icon, () => { });

            applicationJumpListService.Apply();
            ApplicationJumpTaskWrap jumpTask = (ApplicationJumpTaskWrap)nativeJumpList.AppliedList.JumpItems.Single();

            Assert.IsNotNull(jumpTask.IconResourcePath);
            byte[] expectedIcon = StreamHelper.CopyAllBytes(
                AssemblyHelper.GetResourceStream(typeof(ApplicationJumpListServiceTests).Assembly, "Services/ApplicationJumpListService/demoicon.ico", true));
            byte[] actualIcon = File.ReadAllBytes(jumpTask.IconResourcePath);
            AssertHelper.AssertEnumerablesAreEqual(expectedIcon, actualIcon);
        }
        public void AddApplicationJumpTaskWithoutAction_AssignAction_CheckActionRegistered()
        {
            ApplicationJumpTaskInfo jumpTask = new ApplicationJumpTaskInfo()
            {
                Title = "1"
            };

            applicationJumpListService.Items.Add(jumpTask);
            applicationJumpListService.Apply();
            jumpTask.Action = () => { };
            AssertHelper.AssertEnumerablesAreEqual(
                new ApplicationJumpTaskInfo[] {
                jumpTask
            }, jumpActionsManager.RegisteredActions, true
                );
        }
        public void SeveralJumpList()
        {
            IApplicationJumpListService jumpList_2 = new TestApplicationJumpListService(nativeJumpList, jumpActionsManager);

            Assert.IsFalse(jumpList_2.ShowFrequentCategory);
            Assert.IsFalse(jumpList_2.ShowRecentCategory);
            applicationJumpListService.ShowFrequentCategory = true;
            applicationJumpListService.ShowRecentCategory   = true;
            applicationJumpListService.Items.Add("1");
            applicationJumpListService.Apply();
            AssertHelper.AssertEnumerablesAreEqual(new ApplicationJumpItemInfo[] { new ApplicationJumpPathInfo()
                                                                                   {
                                                                                       Path = "1"
                                                                                   } }, jumpList_2.Items, true);
            Assert.IsTrue(jumpList_2.ShowFrequentCategory);
            Assert.IsTrue(jumpList_2.ShowRecentCategory);
        }
        public void TaskbarButtonInfoCollectionBehavior()
        {
            ObservableCollection <int> collection1 = new ObservableCollection <int>();
            MyTestCollection <string>  collection2 = new MyTestCollection <string>();

            collection2.Add("434");
            IDisposable stopBinding = CollectionBindingHelper.Bind(collection1, s => int.Parse(s), collection2, a => a.ToString());

            collection2.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, collection2[0], 0));
            AssertHelper.AssertEnumerablesAreEqual(new int[] { 434 }, collection1);
            collection1.Add(100);
            stopBinding.Dispose();
            collection2.Remove("100");
            CreateAndCheckBinding(() => CollectionBindingHelper.Bind(collection1, s => int.Parse(s), collection2, a => a.ToString()));
            collection2.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, "100", 0));
            AssertHelper.AssertEnumerablesAreEqual(new int[] { 434 }, collection1);
        }
 public void AddJumpPath()
 {
     applicationJumpListService.Items.Add("1");
     applicationJumpListService.Items.Add("category", "2");
     applicationJumpListService.Apply();
     AssertHelper.AssertEnumerablesAreEqual(
         new JumpItem[] {
         new JumpPath()
         {
             Path = "1"
         },
         new JumpPath()
         {
             Path = "2", CustomCategory = "category"
         }
     }, nativeJumpList.AppliedList.JumpItems, true, false
         );
 }
        public void ThumbButtonPropertiesChanged()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ImageSource            imageSource1      = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon1.ico"));
            ImageSource            imageSource2      = ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(AssemblyHelper.GetResourceUri(typeof(TaskbarButtonServiceTests).Assembly, "Icons/icon2.ico"));
            ITaskbarButtonService  taskbarService    = taskbarServiceImpl;
            TaskbarThumbButtonInfo thumbButtonInfo_1 = new TaskbarThumbButtonInfo()
            {
                Description         = "thumbButton1",
                IsEnabled           = true,
                IsInteractive       = true,
                IsBackgroundVisible = false,
                DismissWhenClicked  = false,
                Visibility          = Visibility.Visible,
                ImageSource         = imageSource1
            };

            taskbarService.ThumbButtonInfos.Add(thumbButtonInfo_1);
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].Description         = "thumbButton2";
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].IsEnabled           = false;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].IsInteractive       = false;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].IsBackgroundVisible = true;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].DismissWhenClicked  = true;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].Visibility          = Visibility.Collapsed;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].ImageSource         = imageSource2;
            EnqueueShowRealWindow();
            AssertHelper.AssertEnumerablesAreEqual(new TaskbarThumbButtonInfo[] {
                new TaskbarThumbButtonInfo()
                {
                    Description         = "thumbButton2",
                    IsEnabled           = false,
                    IsInteractive       = false,
                    IsBackgroundVisible = true,
                    DismissWhenClicked  = true,
                    Visibility          = Visibility.Collapsed,
                    ImageSource         = imageSource2
                },
            }, taskbarService.ThumbButtonInfos, true, new string[] { "ItemInfo" });
        }
        public void AddApplicationJumpTask_CheckProperties()
        {
            Action action = () => { };

            applicationJumpListService.Items.Add("category", "1", null, "desc", action);
            applicationJumpListService.Items.Add(new ApplicationJumpTaskInfo()
            {
                Title = "2", IconResourcePath = "D:\\1.ico", IconResourceIndex = 3
            });
            applicationJumpListService.Apply();
            AssertHelper.AssertEnumerablesAreEqual(
                new JumpItem[] {
                new JumpTask()
                {
                    Title = "1", IconResourcePath = null, Description = "desc", CustomCategory = "category"
                },
                new JumpTask()
                {
                    Title = "2", IconResourcePath = "D:\\1.ico", IconResourceIndex = 3
                }
            }, nativeJumpList.AppliedList.JumpItems, true, false
                );
        }
 public void AddJumpPath_CheckRejectedItemsListIsEmpty()
 {
     applicationJumpListService.Items.Add("4");
     AssertHelper.AssertEnumerablesAreEqual(new RejectedApplicationJumpItem[] { }, applicationJumpListService.Apply());
 }
Beispiel #21
0
 void TestEnumerableConverter <TCollection>(IValueConverter converter) where TCollection : IEnumerable
 {
     AssertHelper.AssertEnumerablesAreEqual(new string[] { "0", "1", "2" }, (TCollection)converter.Convert(new int[] { 0, 1, 2 }, typeof(TCollection), null, null));
 }
 public void AddToRecentCategory()
 {
     applicationJumpListService.AddToRecentCategory("1");
     AssertHelper.AssertEnumerablesAreEqual(new string[] { "1" }, nativeJumpList.RecentCategory);
 }