예제 #1
0
		public void MethodPreProcessControlMessage ()
		{
			bool testing_callstack = false;

			MyControl c = new MyControl ();
			Message m = new Message ();
			m.HWnd = c.Handle;
			m.Msg = WM_KEYDOWN;
			m.WParam = (IntPtr)Keys.Down;
			m.LParam = IntPtr.Zero;

			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A1");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.OnPreviewKeyDown);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNeeded, c.PreProcessControlMessage (ref m), "A2");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessCmdKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageProcessed, c.PreProcessControlMessage (ref m), "A3");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNeeded, c.PreProcessControlMessage (ref m), "A4");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageProcessed, c.PreProcessControlMessage (ref m), "A5");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());


			m.Msg = WM_CHAR;
			c.SetState (State.None);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A6");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNeeded, c.PreProcessControlMessage (ref m), "A7");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageProcessed, c.PreProcessControlMessage (ref m), "A8");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());


			m.Msg = WM_SYSCHAR;
			c.SetState (State.None);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A9");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNeeded, c.PreProcessControlMessage (ref m), "A10");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageProcessed, c.PreProcessControlMessage (ref m), "A11");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());


			m.Msg = WM_KEYUP;
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A12");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.OnPreviewKeyDown);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A13");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessCmdKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A14");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A15");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (PreProcessControlState.MessageNotNeeded, c.PreProcessControlMessage (ref m), "A16");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());
		}