public void ExecCtrlSTest02() { var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig11); var entries = config.ApplicationGroups[0].Banks[0].Entries; entries[0].ActionItem.ActionType.Is(ActionType.None); entries[0].ActionItem.ActionValue.IsNull(); var r1 = machine.Exec(entries, Keys.LControlKey, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(entries, Keys.S, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(entries, Keys.S, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(entries, Keys.LControlKey, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); }
public void AutoHideTest01() { var config = ConfigUtil.Deserialize(Resources.TestConfig12); var model = new Model(config, new DummySendKeyCode()); // 初期化チェック model.AutoHide.Is(true); model.MainWindowVisibility.Is(Visibility.Hidden); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "CLIP STUDIO PAINT"); model.MainWindowVisibility.Is(Visibility.Visible); // マウスカーソルが入った model.OnMouse = true; model.MainWindowVisibility.Is(Visibility.Hidden); model.OnMouse = false; model.MainWindowVisibility.Is(Visibility.Visible); model.OnMouse = true; model.MainWindowVisibility.Is(Visibility.Hidden); // OnMouse==true の時に AutoHide が false になったら // MainWindowVisibility==Visible にならなければならない model.AutoHide = false; model.MainWindowVisibility.Is(Visibility.Visible); model.AutoHide = true; model.MainWindowVisibility.Is(Visibility.Hidden); model.OnMouse = false; model.MainWindowVisibility.Is(Visibility.Visible); }
public void ExecCtrlSTest01() { var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig04); var menuItems = config.ApplicationGroups[0].Banks[0].Entries; var r1 = machine.Exec(menuItems, Keys.LControlKey, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.S, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.S, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.LControlKey, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); }
public void SendWaitCallTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig13); var dsc = new DummySendKeyCode(); var model = new Model(config, dsc); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(3); model.Bank.Entries[2].Trigger.Is("H"); model.Bank.Entries[2].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[2].ActionItem.ActionValue.Is("12345"); var state = new KeyboardState { KeyCode = Keys.H }; model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref state)); model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref state)); dsc.EventLog.Count.Is(1); dsc.EventLog[0].Type.Is(DummySendKeyCode.EventType.SendWait); dsc.EventLog[0].Value.Is("12345"); }
public void ExecMenuItemTypeKey04() { var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig04); var menuItems = config.ApplicationGroups[0].Banks[0].Entries; var r1 = machine.Exec(menuItems, Keys.LWin, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.D4, KeyboardUpDown.Down); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.LoadBank); r1.NextBank.IsNull(); r1 = machine.Exec(menuItems, Keys.D4, KeyboardUpDown.Up); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.None); r1.NextBank.Is(""); machine.ClearInternalStatuses(); r1 = machine.Exec(menuItems, Keys.LWin, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); }
public void CtrlSTest01() { var config = ConfigUtil.Deserialize(Resources.TestConfig04); var model = new Model(config, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.TimerEnabled = false; // 停止させないとステップ実行させたりするとおかしくなる model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT"); vm.BankName.Is("(default)"); model.Bank.Entries.Count.Is(2); vm.Buttons.Count.Is(5); model.Bank.Entries[0].Trigger.Is("S"); model.Bank.Entries[0].ActionItem.NextBank.Is("曲線"); var ksLControl = new NativeMethods.KeyboardState { KeyCode = Keys.LControlKey }; var ksS = new NativeMethods.KeyboardState { KeyCode = Keys.S }; vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyDown, ref ksLControl); model.Bank.Entries.Count.Is(2); model.Bank.Name.IsNot("曲線"); model.Bank.Name.Is(""); vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyDown, ref ksS); model.Bank.Entries.Count.Is(2); model.Bank.Name.IsNot("曲線"); model.Bank.Name.Is(""); vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyUp, ref ksS); model.Bank.Entries.Count.Is(2); model.Bank.Name.IsNot("曲線"); model.Bank.Name.Is(""); vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyUp, ref ksLControl); // これで Bank が "曲線" だとおかしい model.Bank.Entries.Count.Is(2); model.Bank.Name.IsNot("曲線"); model.Bank.Name.Is(""); }
public void MenuResetTest03() { var config = ConfigUtil.Deserialize(Resources.TestConfig07); var model = new Model(config, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT B"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(3); vm.Buttons[1].Key.Is("NumPad6"); vm.Buttons[1].LabelText.Is("Bank2"); vm.Buttons[1].ActionItem.ActionType.Is(ActionType.None); vm.Buttons[1].ActionItem.NextBank.Is("Bank2"); model.ProcAction(vm.Buttons[1].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[1].ActionItem, NativeMethods.KeyboardUpDown.Up); vm.BankName.Is("Bank2"); vm.Buttons.Count.Is(3); vm.Buttons[2].Key.Is("NumPad3"); vm.Buttons[2].LabelText.Is("メニューB"); vm.Buttons[2].ActionItem.ActionType.Is(ActionType.Menu); vm.Buttons[2].ActionItem.ActionValue.Is("menu01"); vm.Buttons[2].ActionItem.NextBank.IsNull(); model.ProcAction(vm.Buttons[2].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[2].ActionItem, NativeMethods.KeyboardUpDown.Up); model.IsMenuVisible.Is(true); model.Menu.Name.Is("menu01"); model.Menu.MenuItem.Count.Is(2); model.Menu.MenuItem[0].LabelText.Is("閉じる"); model.Menu.MenuItem[0].ActionItem.ActionType.Is(ActionType.None); model.Menu.MenuItem[0].ActionItem.NextBank.IsNull(); model.Bank.Name.Is("Bank2"); model.ProcAction(model.Menu.MenuItem[0].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(model.Menu.MenuItem[0].ActionItem, NativeMethods.KeyboardUpDown.Up); vm.BankName.Is("Bank2"); model.IsMenuVisible.Is(false); }
public void SelfEventPathThroughTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig13); var dsc = new DummySendKeyCode(); var model = new Model(config, dsc); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(3); model.Bank.Entries[0].Trigger.Is("F"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[0].ActionItem.ActionValue.Is("g"); model.Bank.Entries[1].Trigger.Is("G"); model.Bank.Entries[1].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[1].ActionItem.ActionValue.Is("r"); var ksF = new KeyboardState { KeyCode = Keys.F }; var ksG = new KeyboardState { KeyCode = Keys.G }; // Fを押す model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksF)); // g を送出する dsc.EventLog.Count.Is(1); dsc.EventLog[0].Type.Is(DummySendKeyCode.EventType.SendWait); dsc.EventLog[0].Value.Is("g"); // g を自分で受け取ってしまう var e1 = new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksG); model.SetEvent(e1); var e2 = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksG); model.SetEvent(e2); // g がキャンセルされて、r が送出されてしまっているとまずい。 dsc.EventLog.Count.Is(1); e1.Cancel.Is(false); e2.Cancel.Is(false); model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksF)); dsc.EventLog.Count.Is(1); }
public void MenuResetTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig07); var model = new Model(config, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT B"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(3); vm.Buttons[2].Key.Is("NumPad3"); vm.Buttons[2].LabelText.Is("メニューB"); vm.Buttons[2].ActionItem.ActionType.Is(ActionType.Menu); vm.Buttons[2].ActionItem.ActionValue.Is("menu01"); vm.Buttons[2].ActionItem.NextBank.IsNull(); model.ProcAction(vm.Buttons[2].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[2].ActionItem, NativeMethods.KeyboardUpDown.Up); model.IsMenuVisible.Is(true); model.Menu.Name.Is("menu01"); model.Menu.MenuItem.Count.Is(2); vm.BankName.Is("(default)"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(4); model.Bank.Entries[3].LabelText.Is("キャンセル"); model.Bank.Entries[3].Trigger.Is("NumPad5"); model.Bank.Entries[3].ActionItem.ActionType.Is(ActionType.System); model.Bank.Entries[3].ActionItem.ActionValue.Is("Cancel"); var state = new NativeMethods.KeyboardState { KeyCode = Keys.NumPad5 }; vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyDown, ref state); vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyUp, ref state); vm.BankName.Is("(default)"); model.IsMenuVisible.Is(false); }
public void ExecResetMenu() { var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig09); var bank = config.ApplicationGroups[0].Banks[4]; bank.Name.Is("UndoRedo"); var entries = bank.Entries; entries.Count.Is(4); entries[3].LabelText.Is("キャンセル"); entries[3].Trigger.Is("NumPad5"); entries[3].ActionItem.ActionType.Is(ActionType.System); entries[3].ActionItem.ActionValue.Is("Cancel"); // // Menu 非表示中 // // ReSharper disable RedundantArgumentDefaultValue var r1 = machine.Exec(entries, Keys.NumPad5, KeyboardUpDown.Down, false); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.LoadBank); r1 = machine.Exec(entries, Keys.NumPad5, KeyboardUpDown.Up, false); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.None); // ReSharper restore RedundantArgumentDefaultValue // // Menu 表示中 // r1 = machine.Exec(entries, Keys.NumPad5, KeyboardUpDown.Down, true); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.LoadBank); r1 = machine.Exec(entries, Keys.NumPad5, KeyboardUpDown.Up, true); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.None); }
public void InitializeTest() { var configA = ConfigUtil.Deserialize(Resources.TestConfig05); var configB = ConfigUtil.Deserialize(Resources.TestConfig06); var model = new Model(configA, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(5); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is("前景"); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.Send); vm.Buttons[0].ActionItem.ActionValue.Is(" "); // Config リロード機能 model.Config = configB; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT B"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(4); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is("前景B"); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.Send); vm.Buttons[0].ActionItem.ActionValue.Is(" B"); // Config リロード 時 Bankリセット機能 vm.Buttons[0].ActionItem.NextBank.Is("曲線"); model.ProcAction(vm.Buttons[0].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[0].ActionItem, NativeMethods.KeyboardUpDown.Up); vm.BankName.Is("曲線"); model.Config = configA; vm.ApplicationGroupName.Is("CLIP STUDIO PAINT"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(5); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is("前景"); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.Send); vm.Buttons[0].ActionItem.ActionValue.Is(" "); }
public void BankResetTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig07); var model = new Model(config, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT B"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(3); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is("前景B"); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.Send); vm.Buttons[0].ActionItem.ActionValue.Is(" B"); vm.Buttons[0].ActionItem.NextBank.Is("曲線"); model.ProcAction(vm.Buttons[0].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[0].ActionItem, NativeMethods.KeyboardUpDown.Up); // "曲線" Bank の Entries[2] に // システムコマンド Cancel が設定されていることを確認 vm.BankName.Is("曲線"); model.Bank.Entries.Count.Is(3); model.Bank.Entries[2].LabelText.Is("キャンセル"); model.Bank.Entries[2].Trigger.Is("NumPad5"); model.Bank.Entries[2].ActionItem.ActionType.Is(ActionType.System); model.Bank.Entries[2].ActionItem.ActionValue.Is("Cancel"); model.Bank.Entries[2].ActionItem.NextBank.IsNull(); // Cancel を呼び出す var state = new NativeMethods.KeyboardState { KeyCode = Keys.NumPad5 }; vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyDown, ref state); vm.Event = new KeyboardHookedEventArgs( NativeMethods.KeyboardMessage.KeyUp, ref state); // Bank がリセットされていればOK vm.BankName.Is("(default)"); }
public void ExecNullActionItem() { var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig08); var bank = config.ApplicationGroups[0].Banks[0]; bank.Name.Is(""); var entries = bank.Entries; entries.Count.Is(3); entries[0].Trigger.Is("NumPad9"); entries[0].ActionItem.IsNull(); machine.Exec(entries, Keys.NumPad9, KeyboardUpDown.Down); machine.Exec(entries, Keys.NumPad9, KeyboardUpDown.Up); }
public void ConfigReloadTest01() { var configA = ConfigUtil.Deserialize(Resources.TestConfig05); var configB = ConfigUtil.Deserialize(Resources.TestConfig06); var model = new Model(configA, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(5); vm.Buttons[2].Key.Is("NumPad3"); vm.Buttons[2].LabelText.Is("メニュー"); vm.Buttons[2].ActionItem.ActionType.Is(ActionType.Menu); vm.Buttons[2].ActionItem.ActionValue.Is("menu01"); model.ProcAction(vm.Buttons[2].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[2].ActionItem, NativeMethods.KeyboardUpDown.Up); model.IsMenuVisible.Is(true); // vm は MenuViewModel のインスタンスを公開していないのでとりあえずモデルだけ操作してみる model.Menu.Name.Is("menu01"); model.Menu.MenuItem.Count.Is(2); model.Menu.MenuItem[0].LabelText.Is("閉じる"); model.ProcAction(model.Menu.MenuItem[0].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(model.Menu.MenuItem[0].ActionItem, NativeMethods.KeyboardUpDown.Up); model.IsMenuVisible.Is(false); model.Config = configB; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT B"); vm.BankName.Is("(default)"); vm.Buttons.Count.Is(4); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is("前景B"); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.Send); vm.Buttons[0].ActionItem.ActionValue.Is(" B"); }
public void SystemCommandToggleAutoHideTest() { var configB = ConfigUtil.Deserialize(Resources.TestConfig12); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); var model = new Model(configB, new DummySendKeyCode()); var configBTitle = "Sample12XXXXXXXX"; model.AutoHide.Is(true); model.Basic.Title.Is(configBTitle); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(4); model.Bank.Entries[0].LabelText.Is("自動非表示切り替え"); model.Bank.Entries[0].Trigger.Is("NumPad9"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.System); model.Bank.Entries[0].ActionItem.ActionValue.Is( ConstValues.SystemCommandToggleAutoHide); // Entry ボタンプレス時 model.ProcAction( model.Bank.Entries[0].ActionItem, KeyboardUpDown.Down); model.ProcAction( model.Bank.Entries[0].ActionItem, KeyboardUpDown.Up); model.AutoHide.Is(false); // Entry キープレス時 var state = new KeyboardState { KeyCode = Keys.NumPad9 }; model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref state)); model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref state)); model.AutoHide.Is(true); }
public void DefaultMenuItemBackgrowndColor() { var config = ConfigUtil.Deserialize(Resources.TestConfig08); var model = new Model(config, new DummySendKeyCode()); model.Basic.Title.Is("Title01"); model.ApplicationGroups.IsNotNull(); model.ApplicationGroup.Name.Is(""); model.Bank.Name.Is(""); // 該当あり model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.IsNotNull(); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); model.Bank.Name.Is(""); model.IsMenuVisible.IsFalse(); model.Bank.Entries.Count.Is(3); model.Bank.Entries[0].LabelText.Is("#F000"); model.Bank.Entries[0].Background.ToString() .Is(Util.ConvertFromString <Brush>("#F000").ToString()); model.Bank.Entries[1].LabelText.Is("No BackColor"); model.Bank.Entries[1].Background.IsNotNull(); model.Bank.Entries[1].Background.ToString() .Is(Util.DefaultBrush.ToString()); var menus = model.ApplicationGroup.Menus; menus.Count.Is(1); menus[0].Name.Is("menu01"); menus[0].MenuItem.Count.Is(2); var items = menus[0].MenuItem; items[0].LabelText.Is("#F0F0"); items[0].Background.ToString() .Is(Util.ConvertFromString <Brush>("#F0F0").ToString()); items[1].LabelText.Is("No BackColor"); items[1].Background.IsNotNull(); items[1].Background.ToString().Is(Util.DefaultBrush.ToString()); }
public void DeserializeTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig01); var applicationGroup = config.ApplicationGroups[0]; applicationGroup.Name.Is("CLIP STUDIO PAINT"); var menuGroup = applicationGroup.Banks[0]; menuGroup.Name.Is(string.Empty); var menus = applicationGroup.Menus; menus.Count.Is(1); var menu = menus[0]; menu.Name.Is("menu01"); menu.MenuItem.Count.Is(3); menu.MenuItem[2].ActionItem.IsNotNull(); }
public void SelfEventCancelTest() { ExecResult r1; var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig13); var bank = config.ApplicationGroups[0].Banks[0]; bank.Name.Is(""); var entries = bank.Entries; entries.Count.Is(3); entries[0].Trigger.Is("F"); entries[0].ActionItem.ActionType.Is(ActionType.Send); entries[0].ActionItem.ActionValue.Is("g"); entries[1].Trigger.Is("G"); entries[1].ActionItem.ActionType.Is(ActionType.Send); entries[1].ActionItem.ActionValue.Is("r"); // F を Down する r1 = machine.Exec(entries, Keys.F, KeyboardUpDown.Down); // g が発生して、これを受け取ってしまう。 r1 = machine.Exec(entries, Keys.G, KeyboardUpDown.Down); // g はキャンセルしてはいけない r1.ShouldCancel.Is(false); r1.ActionType.Is(ActionType.None); r1.Status.Is(ExecStatus.None); // 同上 r1 = machine.Exec(entries, Keys.G, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.ActionType.Is(ActionType.None); r1.Status.Is(ExecStatus.None); // こっちはキャンセルしないといけない r1 = machine.Exec(entries, Keys.F, KeyboardUpDown.Up); r1.ShouldCancel.Is(true); r1.ActionType.Is(ActionType.None); }
public void NullMenuItemTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig10); var model = new Model(config, new DummySendKeyCode()); var vm = new MainWindowViewModel(model); vm.Initialize(); model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); vm.ApplicationGroupName.Is("CLIP STUDIO PAINT"); vm.BankName.Is("(default)"); model.Bank.Entries.Count.Is(4); vm.Buttons.Count.Is(4); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is("前景"); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.None); vm.Buttons[0].ActionItem.NextBank.Is("EmptyBank"); vm.Buttons[0].Background.ToString() .Is(Util.ConvertFromString <Brush>("#F0F0").ToString()); model.ProcAction(vm.Buttons[0].ActionItem, NativeMethods.KeyboardUpDown.Down); model.ProcAction(vm.Buttons[0].ActionItem, NativeMethods.KeyboardUpDown.Up); vm.BankName.Is("EmptyBank"); model.Bank.Entries.Count.Is(0); vm.Buttons.Count.Is(4); vm.Buttons[0].Key.Is("NumPad9"); vm.Buttons[0].LabelText.Is(""); vm.Buttons[0].ActionItem.ActionType.Is(ActionType.None); vm.Buttons[0].ActionItem.ActionValue.Is(""); vm.Buttons[0].ActionItem.NextBank.IsNull(); vm.Buttons[0].Background.ToString() .Is(Util.DefaultBrush.ToString()); }
public void ExecMdifireKey01() { var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig04); var menuItems = config.ApplicationGroups[0].Banks[0].Entries; var r1 = machine.Exec(menuItems, Keys.LControlKey, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.LControlKey, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.LControlKey, KeyboardUpDown.Down); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); // 長期間同じキーをDownしていると Down イベントは複数回発生するが、 // Up イベントは1度しか発生しない r1 = machine.Exec(menuItems, Keys.LControlKey, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(menuItems, Keys.S, KeyboardUpDown.Down); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.LoadBank); r1 = machine.Exec(menuItems, Keys.S, KeyboardUpDown.Up); r1.ShouldCancel.Is(true); r1.Status.Is(ExecStatus.None); }
public void NoMatchingApplicationGroupTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig07); var model = new Model(config, new DummySendKeyCode()); model.Basic.Title.Is("Title01"); model.ApplicationGroups.IsNotNull(); model.ApplicationGroup.Name.Is(""); model.Bank.Name.Is(""); // 該当あり model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.IsNotNull(); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); model.Bank.Name.Is(""); model.IsMenuVisible.IsFalse(); model.MainWindowVisibility.Is(Visibility.Visible); // 該当なし model.WindowInfo = new WindowInfo("booboo.exe", "BOOBOO PAINT"); model.ApplicationGroups.IsNotNull(); model.ApplicationGroup.Name.Is(""); model.IsMenuVisible.IsFalse(); model.MainWindowVisibility.Is(Visibility.Hidden); var state = new KeyboardState { KeyCode = Keys.NumPad5 }; var e = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref state); model.SetEvent(e); }
public void SerializeTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig02); var applicationGroup = config.ApplicationGroups[0]; applicationGroup.Name.Is("CLIP STUDIO PAINT"); var bank = applicationGroup.Banks[0]; bank.Name.Is(string.Empty); var mi = bank.Entries[0]; mi.Trigger.Is("Num9"); var miActionItem = mi.ActionItem; miActionItem.ActionType.Is(ActionType.Send); miActionItem.ActionValue.Is(" "); using (var stream = new MemoryStream()) { ConfigUtil.Serialize(config, stream); var uni = Encoding.GetEncoding("UTF-8").GetString(stream.ToArray()); uni.Contains("ActionValue=\" \"").IsTrue(); } }
private void RefreshConfigData() { ConfigModel.JsonConfig config = null; using (StreamReader r = new StreamReader(_jsonFileName, System.Text.Encoding.Default)) { string json = r.ReadToEnd(); config = ConfigUtil.Deserialize <ConfigModel.JsonConfig>(json); } if (config != null && (config.Alert != null || config.AlertRecord != null || config.Apikey != null || config.Focus != null || config.Period != null)) { this._config = config; } else { //如果抓不到config 就init一個新的 UpdateJsonConfigData(new ConfigModel.JsonConfig() { Apikey = "", Alert = new List <ConfigModel.AlertRule>(), AlertRecord = new List <ConfigModel.AlertRecord>(), Focus = new ConfigModel.FocusSetting(), Period = new List <ConfigModel.PeriodRule>() }); } }
public void SendSelfKeyTest() { var ksF = new KeyboardState { KeyCode = Keys.F }; var config = ConfigUtil.Deserialize(Resources.TestConfig16); var dsc = new DummySendKeyCode(); var model = new Model(config, dsc); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(1); model.Bank.Entries[0].Trigger.Is("F"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.None); model.Bank.Entries[0].ActionItem.ActionValue.IsNull(); model.Bank.Entries[0].ActionItem.NextBank.Is("Bank02"); // f(down) -> f(up) model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksF)); model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksF)); dsc.EventLog.Count.Is(0); model.Bank.Name.Is("Bank02"); model.Bank.Entries.Count.Is(1); model.Bank.Entries[0].Trigger.Is("F"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[0].ActionItem.ActionValue.Is("f"); model.Bank.Entries[0].ActionItem.NextBank.Is(""); /* * 処理の時系列が反転するけれども、 * dsc.SendWaitLambda に処理をセットしておくと SendWait() の中で呼び * 出される。 * これにより、ProcAction() 中で呼び出される SendWait() の中から呼び * 出されたイベントが model の中に到達してそれがキャンセルされずに、 * 操作対象のアプリケーションに届くことを 確認できる。 * 検証に失敗した場合は dsc.SendWaitLambdaExceptions に記録されるので、 * 件数を検証する必要がある。 */ dsc.SendWaitLambda = () => { var ksF2 = new KeyboardState { KeyCode = Keys.F }; var e1 = new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksF2); model.SetEvent(e1); e1.Cancel.Is(false); dsc.EventLog.Count.Is(1); var e2 = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksF2); model.SetEvent(e2); e2.Cancel.Is(false); dsc.EventLog.Count.Is(1); }; // action を呼び出す。この中で SendWait() が呼び出されて、 // dsc.SendWaitLambda が呼び出され、上記の検証が走る var e3 = new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksF); model.SetEvent(e3); e3.Cancel.Is(true); dsc.SendWaitLambda = null; // 余分に呼び出されないようにクリア dsc.SendWaitLambdaExceptions.Count.Is(0); dsc.EventLog.Count.Is(1); // ここらへんで LoadBank が起こる model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(1); // 最後にユーザー入力の f(up) が来る var e4 = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksF); model.SetEvent(e4); e4.Cancel.Is(true); dsc.EventLog.Count.Is(1); }
public void SelfEventCancelTwiceTest() { ExecResult r1; var machine = new StateMachine(); var config = ConfigUtil.Deserialize(Resources.TestConfig14); var bank = config.ApplicationGroups[0].Banks[0]; bank.Name.Is(""); var entries = bank.Entries; entries.Count.Is(2); entries[0].Trigger.Is("F"); entries[0].ActionItem.ActionType.Is(ActionType.None); entries[0].ActionItem.ActionValue.IsNull(); entries[0].ActionItem.NextBank.Is("Bank01"); entries[1].Trigger.Is("R"); entries[1].ActionItem.ActionType.Is(ActionType.Send); entries[1].ActionItem.ActionValue.Is("a"); // F を Down する r1 = machine.Exec(entries, Keys.F, KeyboardUpDown.Down); r1.Status.Is(ExecStatus.LoadBank); r1.NextBank.Is("Bank01"); // Bank01 がロードされる bank = config.ApplicationGroups[0].Banks[1]; bank.Name.Is("Bank01"); entries = bank.Entries; entries.Count.Is(2); entries[0].Trigger.Is("G"); entries[0].ActionItem.ActionType.Is(ActionType.Send); entries[0].ActionItem.ActionValue.Is("r"); entries[0].ActionItem.NextBank.Is(""); entries[1].Trigger.Is("R"); entries[1].ActionItem.ActionType.Is(ActionType.Send); entries[1].ActionItem.ActionValue.Is("b"); // g(down) r1 = machine.Exec(entries, Keys.G, KeyboardUpDown.Down); r1.ShouldCancel.Is(true); r1.ActionType.Is(ActionType.Send); r1.ActionValue.Is("r"); r1.Status.Is(ExecStatus.LoadBank); // r が発生して、これを受け取ってしまう。 r1 = machine.Exec(entries, Keys.R, KeyboardUpDown.Down); // r はキャンセルしてはいけない r1.ShouldCancel.Is(false); r1.ActionType.Is(ActionType.None); r1.Status.Is(ExecStatus.None); // 同上 r1 = machine.Exec(entries, Keys.R, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.ActionType.Is(ActionType.None); r1.Status.Is(ExecStatus.None); // このあたりで default Bank がロードされる bank = config.ApplicationGroups[0].Banks[0]; bank.Name.Is(""); entries = bank.Entries; entries.Count.Is(2); r1 = machine.Exec(entries, Keys.G, KeyboardUpDown.Up); r1.ShouldCancel.Is(true); r1 = machine.Exec(entries, Keys.F, KeyboardUpDown.Up); // // ここから2週目 // // F を Down する r1 = machine.Exec(entries, Keys.F, KeyboardUpDown.Down); r1.Status.Is(ExecStatus.LoadBank); r1.NextBank.Is("Bank01"); // Bank01 がロードされる bank = config.ApplicationGroups[0].Banks[1]; bank.Name.Is("Bank01"); entries = bank.Entries; entries.Count.Is(2); // g(down) r1 = machine.Exec(entries, Keys.G, KeyboardUpDown.Down); r1.ShouldCancel.Is(true); r1.ActionType.Is(ActionType.Send); r1.ActionValue.Is("r"); r1.Status.Is(ExecStatus.LoadBank); // r が発生して、これを受け取ってしまう。 r1 = machine.Exec(entries, Keys.R, KeyboardUpDown.Down); // r はキャンセルしてはいけない r1.ShouldCancel.Is(false); r1.ActionType.Is(ActionType.None); r1.Status.Is(ExecStatus.None); // 同上 r1 = machine.Exec(entries, Keys.R, KeyboardUpDown.Up); r1.ShouldCancel.Is(false); r1.ActionType.Is(ActionType.None); r1.Status.Is(ExecStatus.None); r1 = machine.Exec(entries, Keys.G, KeyboardUpDown.Up); r1.ShouldCancel.Is(true); r1 = machine.Exec(entries, Keys.F, KeyboardUpDown.Up); }
public void ProceActionTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig15); var dsc = new DummySendKeyCode(); var model = new Model(config, dsc); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(2); model.Bank.Entries[0].Trigger.Is("F"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[0].ActionItem.ActionValue.Is("a"); model.Bank.Entries[1].Trigger.Is("G"); model.Bank.Entries[1].ActionItem.ActionType.Is(ActionType.Menu); model.Bank.Entries[1].ActionItem.ActionValue.Is("01"); var action = model.Bank.Entries[1].ActionItem; model.ProcAction(action, KeyboardUpDown.Down); model.ProcAction(action, KeyboardUpDown.Up); model.Menu.Name.Is("01"); model.Menu.MenuItem.Count.Is(1); model.Menu.MenuItem[0].ActionItem.ActionType.Is(ActionType.Send); model.Menu.MenuItem[0].ActionItem.ActionValue.Is("f"); /* * 処理の時系列が反転するけれども、 * dsc.SendWaitLambda に処理をセットしておくと SendWait() の中で呼び * 出される。 * これにより、ProcAction() 中で呼び出される SendWait() の中から呼び * 出されたイベントが model の中に到達してそれがキャンセルされずに、 * 操作対象のアプリケーションに届くことを 確認できる。 * 検証に失敗した場合は dsc.SendWaitLambdaExceptions に記録されるので、 * 件数を検証する必要がある。 */ dsc.SendWaitLambda = () => { var ksF = new KeyboardState { KeyCode = Keys.F }; var e1 = new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksF); model.SetEvent(e1); e1.Cancel.Is(false); dsc.EventLog.Count.Is(1); var e2 = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksF); model.SetEvent(e2); e2.Cancel.Is(false); dsc.EventLog.Count.Is(1); }; // action を呼び出す。この中で SendWait() が呼び出されて、 // dsc.SendWaitLambda が呼び出され、上記の検証が走る action = model.Menu.MenuItem[0].ActionItem; model.ProcAction(action, KeyboardUpDown.Down); dsc.SendWaitLambda = null; // 余分に呼び出されないようにクリア dsc.SendWaitLambdaExceptions.Count.Is(0); dsc.EventLog.Count.Is(1); dsc.EventLog[0].Type.Is(DummySendKeyCode.EventType.SendWait); dsc.EventLog[0].Value.Is("f"); model.ProcAction(action, KeyboardUpDown.Up); dsc.EventLog.Count.Is(1); }
public void SendAfterLoadBankTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig14); var dsc = new DummySendKeyCode(); var model = new Model(config, dsc); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(2); model.Bank.Entries[0].Trigger.Is("F"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.None); model.Bank.Entries[0].ActionItem.ActionValue.IsNull(); model.Bank.Entries[0].ActionItem.NextBank.Is("Bank01"); model.Bank.Entries[1].Trigger.Is("R"); model.Bank.Entries[1].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[1].ActionItem.ActionValue.Is("a"); model.Bank.Entries[1].ActionItem.NextBank.Is(""); var ksF = new KeyboardState { KeyCode = Keys.F }; var ksG = new KeyboardState { KeyCode = Keys.G }; var ksR = new KeyboardState { KeyCode = Keys.R }; // Fを押す model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksF)); dsc.EventLog.Count.Is(0); // この時点で LoadBank が完了していなければならない。 model.Bank.Name.Is("Bank01"); model.Bank.Entries.Count.Is(2); model.Bank.Entries[0].Trigger.Is("G"); model.Bank.Entries[0].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[0].ActionItem.ActionValue.Is("r"); model.Bank.Entries[0].ActionItem.NextBank.Is(""); model.Bank.Entries[1].Trigger.Is("R"); model.Bank.Entries[1].ActionItem.ActionType.Is(ActionType.Send); model.Bank.Entries[1].ActionItem.ActionValue.Is("b"); model.Bank.Entries[1].ActionItem.NextBank.Is(""); // f(down)のまま g(down) を送出する model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksG)); // この時に SendWait("r") が実行済みでなければならない。 dsc.EventLog.Count.Is(1); dsc.EventLog[0].Type.Is(DummySendKeyCode.EventType.SendWait); dsc.EventLog[0].Value.Is("r"); // 当然、LoadBank も完了済みでなければならない。 model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(2); // 自分で出した r を受け取ってしまう。 model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref ksR)); dsc.EventLog.Count.Is(1); model.SetEvent(new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksR)); dsc.EventLog.Count.Is(1); // g(up) と f(up) はどこかのタイミングで発生する。 // これらのいずれもキャンセルされなければならない。 var e1 = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksG); model.SetEvent(e1); e1.Cancel.Is(true); dsc.EventLog.Count.Is(1); var e2 = new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref ksF); model.SetEvent(e2); e2.Cancel.Is(true); dsc.EventLog.Count.Is(1); }
public void SystemCommandCancelTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig09); var model = new Model(config, new DummySendKeyCode()); model.Basic.Title.Is("Sample01"); model.Basic.Buttons.Count.Is(4); model.ApplicationGroups.IsNotNull(); model.ApplicationGroup.Name.Is(""); model.Bank.Name.Is(""); // 該当あり model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.IsNotNull(); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.IsMenuVisible.IsFalse(); model.Bank.Entries.Count.Is(4); model.Bank.Entries[3].LabelText.Is("キャンセル"); model.Bank.Entries[3].Trigger.Is("NumPad5"); model.Bank.Entries[3].ActionItem.ActionType.Is(ActionType.System); model.Bank.Entries[3].ActionItem.ActionValue.Is("Cancel"); // // とりあえずエラーが出ないことを確認 // // Entry ボタンプレス時 model.ProcAction( model.Bank.Entries[3].ActionItem, KeyboardUpDown.Down); model.ProcAction( model.Bank.Entries[3].ActionItem, KeyboardUpDown.Up); // Entry キープレス時 var state = new KeyboardState { KeyCode = Keys.NumPad5 }; model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref state)); model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref state)); // // メニューのリセットの確認 // model.Bank.Entries[2].LabelText.Is("メニュー"); model.Bank.Entries[2].Trigger.Is("NumPad3"); model.Bank.Entries[2].ActionItem.ActionType.Is(ActionType.Menu); model.Bank.Entries[2].ActionItem.ActionValue.Is("menu01"); // menu01 を読み込ませる model.ProcAction( model.Bank.Entries[2].ActionItem, KeyboardUpDown.Down); model.ProcAction( model.Bank.Entries[2].ActionItem, KeyboardUpDown.Up); model.IsMenuVisible.Is(true); model.Menu.Name.Is("menu01"); // キャンセル処理させる model.ProcAction( model.Bank.Entries[3].ActionItem, KeyboardUpDown.Down); model.ProcAction( model.Bank.Entries[3].ActionItem, KeyboardUpDown.Up); model.IsMenuVisible.Is(false); model.Bank.Name.Is(""); }
public void NullActionItemTest() { var config = ConfigUtil.Deserialize(Resources.TestConfig08); var model = new Model(config, new DummySendKeyCode()); model.Basic.Title.Is("Title01"); model.ApplicationGroups.IsNotNull(); model.ApplicationGroup.Name.Is(""); model.Bank.Name.Is(""); // 該当あり model.WindowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); model.ApplicationGroup.IsNotNull(); model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT B"); model.Bank.Name.Is(""); model.IsMenuVisible.IsFalse(); model.Bank.Entries.Count.Is(3); model.Bank.Entries[0].LabelText.Is("#F000"); model.Bank.Entries[0].Background.ToString() .Is(Util.ConvertFromString <Brush>("#F000").ToString()); model.Bank.Entries[0].Trigger.Is("NumPad9"); model.Bank.Entries[0].ActionItem.IsNull(); // Entry ボタンプレス時 model.ProcAction(model.Bank.Entries[0].ActionItem, KeyboardUpDown.Down); model.ProcAction(model.Bank.Entries[0].ActionItem, KeyboardUpDown.Up); // Entry キープレス時 var state = new KeyboardState { KeyCode = Keys.NumPad5 }; model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref state)); model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref state)); var menus = model.ApplicationGroup.Menus; menus.Count.Is(1); menus[0].Name.Is("menu01"); menus[0].MenuItem.Count.Is(2); var items = menus[0].MenuItem; items[0].LabelText.Is("#F0F0"); items[0].Background.ToString() .Is(Util.ConvertFromString <Brush>("#F0F0").ToString()); items[0].ActionItem.IsNull(); // MenuItem ボタンプレス時 (キープレスは今のところありえない) model.ProcAction(items[0].ActionItem, KeyboardUpDown.Down); model.ProcAction(items[0].ActionItem, KeyboardUpDown.Up); }
public void SystemCommandReloadConfigTest() { var configB = ConfigUtil.Deserialize(Resources.TestConfig12); var windowInfo = new WindowInfo("ClipStudioPaint.exe", "新規ファイル.clip - CLIP STUDIO PAINT"); var model = new Model(); var defaultConfigTitle = model.Basic.Title; var configBTitle = "Sample12XXXXXXXX"; // 念のため確認 defaultConfigTitle.IsNot(configBTitle); model.Config = configB; model.Basic.Title.Is(configBTitle); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(4); model.Bank.Entries[3].LabelText.Is("再読み込み"); model.Bank.Entries[3].Trigger.Is("NumPad5"); model.Bank.Entries[3].ActionItem.ActionType.Is(ActionType.System); model.Bank.Entries[3].ActionItem.ActionValue.Is("ReloadConfig"); // Entry ボタンプレス時 model.ProcAction( model.Bank.Entries[3].ActionItem, KeyboardUpDown.Down); model.ProcAction( model.Bank.Entries[3].ActionItem, KeyboardUpDown.Up); // デフォルトの config.xml が読み込まれていればOK model.Basic.Title.Is(defaultConfigTitle); // 再度 configB を読み込み model.Config = configB; model.Basic.Title.Is(configBTitle); model.WindowInfo = windowInfo; model.ApplicationGroup.Name.Is("CLIP STUDIO PAINT"); model.Bank.Name.Is(""); model.Bank.Entries.Count.Is(4); model.Bank.Entries[3].LabelText.Is("再読み込み"); model.Bank.Entries[3].Trigger.Is("NumPad5"); model.Bank.Entries[3].ActionItem.ActionType.Is(ActionType.System); model.Bank.Entries[3].ActionItem.ActionValue.Is("ReloadConfig"); // Entry キープレス時 var state = new KeyboardState { KeyCode = Keys.NumPad5 }; model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyDown, ref state)); model.SetEvent( new KeyboardHookedEventArgs( KeyboardMessage.KeyUp, ref state)); // デフォルトの config.xml が読み込まれていればOK model.Basic.Title.Is(defaultConfigTitle); }