Exemple #1
0
        private  void AddMouseActionNodesToActionList(List<Win32API.MouseEvent> datas, IEnumerable<XElement> re)
        {
            foreach (var item in re)
            {
                Win32API.MouseEvent mouseEvent = new Win32API.MouseEvent();
                mouseEvent.delayTime = Convert.ToInt32(item.Attribute("DelayTime").Value);

                string pointInfo = item.Element("Position").Value;
                pointInfo = pointInfo.Substring(1, pointInfo.Length - 2);
                string[] xy = (pointInfo.Split(','));
                mouseEvent.pt.x = Convert.ToInt32(xy[0]);
                mouseEvent.pt.y = Convert.ToInt32(xy[1]);

                JudgeMouseevent(item, ref mouseEvent);

                datas.Add(mouseEvent);
            }
        }
 public void WriteDataTest1()
 {
     MActionRecorderLinq target = new MActionRecorderLinq();
     string mouseEvents = "WM_LBUTTONDOWN";
     MSLLHOOKSTRUCT myMouse = new MSLLHOOKSTRUCT() { pt = new Win32API.POINT(0, 0) };
     int delayTime = 10;
     target.WriteData(mouseEvents, myMouse, delayTime);
     target.SaveActions();
     Win32API.MouseEvent Expected = new Win32API.MouseEvent()
     {
         dwFlags = Win32API.MouseEventFlag.LeftDown,
         delayTime = 10,
         pt = new Win32API.POINT(0, 0)
     };
     var actual = target.GetDatas()[0];
     Assert.AreEqual(Expected, actual);
 }
 public void JudgeMouseeventTest()
 {
     KBMActionRecorderLinq_Accessor target = new KBMActionRecorderLinq_Accessor();
     XElement item = new XElement(
         "Action", new XAttribute("Type", "MouseAct"),
         new XAttribute("DelayTime", 10),
      new XElement("Position", new Win32API.POINT(0, 0)),
      new XElement("MouseEvent", "WM_LBUTTONDOWN"));
     Win32API.MouseEvent mouseEvent = new Win32API.MouseEvent()
     {
         delayTime = 10,
         dwFlags = Miku.Client.Win32API.MouseEventFlag.LeftDown,
         pt = new Win32API.POINT(0, 0)
     };
     Win32API.MouseEvent mouseEventExpected = new Win32API.MouseEvent()
     {
         delayTime = 10,
         
         pt = new Win32API.POINT(0, 0)
     };
     target.JudgeMouseevent(item, ref mouseEventExpected);
     
     Assert.AreEqual(mouseEventExpected, mouseEvent);
    
 }
 public void GetMouseActionDatasTest()
 {
     KBMActionRecorderLinq target = new KBMActionRecorderLinq();
     target.WriteData("WM_LBUTTONDOWN", new MSLLHOOKSTRUCT() { pt = new Win32API.POINT(0, 0) }, 10);
     target.SaveActions();
     Win32API.MouseEvent[] expected = new Win32API.MouseEvent[]
     {
          new Win32API.MouseEvent() 
         {
             delayTime = 10, 
             dwFlags = Miku.Client.Win32API.MouseEventFlag.LeftDown ,
             pt=new Win32API.POINT(0, 0)
         }
     };
     Win32API.MouseEvent[] actual;
     actual = target.GetMouseActionDatas();
     Assert.AreEqual(expected[0], actual[0]);
 }
 public void JudgeMouseeventTest()
 {
     MActionRecorderLinq_Accessor target = new MActionRecorderLinq_Accessor();            
     Win32API.MouseEvent mouseEvent = new Win32API.MouseEvent()
     {
         dwFlags=Win32API.MouseEventFlag.LeftDown
     };
     XElement item = new XElement(
         "Action", new XAttribute("Type", "MouseAct"),
         new XAttribute("DelayTime", 10),
       new XElement("Position", null),
       new XElement("MouseEvent", mouseEvent));
     Win32API.MouseEvent mouseEventExpected = new Win32API.MouseEvent() 
     { 
         dwFlags = Win32API.MouseEventFlag.LeftDown 
     };  
     target.JudgeMouseevent(item, ref mouseEvent);
     
     Assert.AreEqual(mouseEventExpected, mouseEvent);           
 }