Esempio n. 1
0
        public void TypingTest()
        {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\EditorTests.sln");

                // http://pytools.codeplex.com/workitem/139
                TypingTest(app, project, "DecoratorOnFunction.py", 0, 0, @"@classmethod
def f(): pass
", () => {
                    Keyboard.Type("\r");
                    Keyboard.Type("↑");
                    Keyboard.Type("@@");
                    System.Threading.Thread.Sleep(5000);
                    Keyboard.Backspace();
                    Keyboard.Type("classmethod");
                    System.Threading.Thread.Sleep(5000);
                });

                // http://pytools.codeplex.com/workitem/151
                TypingTest(app, project, "DecoratorInClass.py", 1, 4, @"class C:
    @classmethod
    def f(self):
        pass
", () => {
                    Keyboard.Type("@");
                    System.Threading.Thread.Sleep(5000);
                    Keyboard.Type("classmethod");
                    System.Threading.Thread.Sleep(5000);

                    // VS Bug
                    // 72635 Exception occurrs and you're not prompted to save file when you close it while completion list is up.
                    Keyboard.Type(System.Windows.Input.Key.Escape);
                });
            }
        }
Esempio n. 2
0
    private void Update()
    {
        var shifted = Input.GetKey(KeyCode.LeftShift);

        for (var keyCode = KeyCode.A; keyCode <= KeyCode.Z; keyCode++)
        {
            if (Input.GetKeyDown(keyCode))
            {
                var character = keyCode.ToString();

                keyboard.AddCharacter(shifted ? character.ToUpper() : character.ToLower());
            }
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            HandleSubmit(keyboard.text);
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            keyboard.SetText("");
        }
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            keyboard.Backspace();
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            keyboard.AddCharacter(" ");
        }
    }
Esempio n. 3
0
        public void SignaturesTest()
        {
            var project = Project("SignaturesTest",
                                  Compile("server", "function f(a, b, c) { }\r\n\r\n")
                                  );

            using (var solution = project.Generate().ToVs()) {
                var server = solution.OpenItem("SignaturesTest", "server.js");

                server.MoveCaret(3, 1);

                Keyboard.Type("f(");

                using (var sh = server.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("a", session.SelectedSignature.CurrentParameter.Name);
                }

                Keyboard.Backspace();
                Keyboard.Backspace();

                Keyboard.Type("new f(");

                using (var sh = server.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("a", session.SelectedSignature.CurrentParameter.Name);
                }
            }
        }
Esempio n. 4
0
        public void AddText()
        {
            if (Time.time - timer > timeDelay)
            {
                switch (TextType)
                {
                case Text_Type.Backspace:

                    keyboard.Backspace();


                    break;

                case Text_Type.Enter:

                    keyboard.Enter();

                    break;

                default:
                    keyboard.AddText(key);
                    break;
                }
                timer = Time.time;
            }
        }
Esempio n. 5
0
    void Start()
    {
        keyboard = transform.parent.GetComponent <Keyboard> ();
        audioSrc = GetComponent <AudioSource> ();

        GetComponent <Button> ().onClick.AddListener(() => {
            audioSrc.Play();
            keyboard.Backspace();
        });
    }
Esempio n. 6
0
        public void ProjectProperties()
        {
            var filename = Path.Combine(TestData.GetTempPath(), Path.GetRandomFileName());

            var project = Project("ProjectProperties",
                                  Compile("server"),
                                  Property(NodeProjectProperty.Environment, "fob=1\r\nbar=2;3\nbaz=4"),
                                  Property(NodeProjectProperty.DebuggerPort, "1234"),
                                  Property(CommonConstants.StartupFile, "server.js")
                                  );

            using (var solution = project.Generate().ToVs())
            {
                var projectNode = solution.WaitForItem("ProjectProperties");
                AutomationWrapper.Select(projectNode);

                solution.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");
                AutomationElement doc = null;
                for (int i = 0; i < 10; i++)
                {
                    doc = ((VisualStudioInstance)solution).App.GetDocumentTab("ProjectProperties");
                    if (doc != null)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
                Assert.IsNotNull(doc, "Failed to find project properties tab");

                var debuggerPort =
                    new TextBox(
                        new AutomationWrapper(doc).FindByAutomationId("_debuggerPort")
                        );
                var envVars = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_envVars")
                    );

                Assert.AreEqual(debuggerPort.Value, "1234");
                Assert.AreEqual(envVars.Value, "fob=1\r\nbar=2;3\r\nbaz=4");

                debuggerPort.Value = "2468";

                // Multi-line text box does not support setting value via automation.
                envVars.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("fob=0\nbar=0;0\nbaz=0");

                solution.ExecuteCommand("File.SaveAll");

                var projFile = File.ReadAllText(solution.GetProject("ProjectProperties").FullName);
                Assert.AreNotEqual(-1, projFile.IndexOf("<DebuggerPort>2468</DebuggerPort>"));
                Assert.AreNotEqual(-1, projFile.IndexOf("<Environment>fob=0\r\nbar=0;0\r\nbaz=0</Environment>"));
            }
        }
        public void TestProjectProperties()
        {
            var filename = Path.Combine(TestData.GetTempPath(), Path.GetRandomFileName());

            var project = Project("ProjectProperties",
                                  Compile("server"),
                                  Property("StartupFile", "server.js")
                                  );

            using (var solution = project.Generate().ToVs()) {
                var projectNode = solution.WaitForItem("ProjectProperties");
                AutomationWrapper.Select(projectNode);

                solution.App.Dte.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");
                AutomationElement doc = null;
                for (int i = 0; i < 10; i++)
                {
                    doc = solution.App.GetDocumentTab("ProjectProperties");
                    if (doc != null)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
                Assert.IsNotNull(doc, "Failed to find project properties tab");

                var nodeExeArguments = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_nodeArguments")
                    );
                var debuggerMachineName = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_debuggerMachineName")
                    );

                debuggerMachineName.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("10.11.22.33");

                nodeExeArguments.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("--no-console --debug");

                solution.App.Dte.ExecuteCommand("File.SaveAll");

                var projFile = File.ReadAllText(solution.Project.FullName);
                Assert.AreNotEqual(-1, projFile.IndexOf("<DebuggerMachineName>10.11.22.33</DebuggerMachineName>"));
                Assert.AreNotEqual(-1, projFile.IndexOf("<NodeExeArguments>--no-console --debug</NodeExeArguments>"));
            }
        }
Esempio n. 8
0
        public void SignaturesByName(PythonVisualStudioApp app)
        {
            var project = app.OpenProject(app.CopyProjectForTest(@"TestData\Signatures.sln"));

            var item   = project.ProjectItems.Item("sigs.py");
            var window = item.Open();

            window.Activate();

            var doc = app.GetDocument(item.Document.FullName);

            doc.SetFocus();

            ((UIElement)doc.TextView).Dispatcher.Invoke((Action)(() => {
                doc.TextView.Caret.MoveTo(new SnapshotPoint(doc.TextView.TextBuffer.CurrentSnapshot, doc.TextView.TextBuffer.CurrentSnapshot.Length));
                ((UIElement)doc.TextView).Focus();
            }));

            //doc.WaitForAnalysisAtCaretAsync().WaitAndUnwrapExceptions();

            Keyboard.Type("f");
            System.Threading.Thread.Sleep(500);
            Keyboard.Type("(");

            using (var sh = doc.WaitForSession <ISignatureHelpSession>()) {
                var session = sh.Session;
                Assert.IsNotNull(session, "No session active");
                Assert.IsNotNull(session.SelectedSignature, "No signature selected");

                WaitForCurrentParameter(session, "a");
                Assert.AreEqual("a", session.SelectedSignature.CurrentParameter.Name);

                Keyboard.Type("b=");

                WaitForCurrentParameter(session, "b");
                Assert.AreEqual("b", session.SelectedSignature.CurrentParameter.Name);
                window.Activate();

                Keyboard.Type("42,");

                WaitForNoCurrentParameter(session);
                Assert.AreEqual(null, session.SelectedSignature.CurrentParameter);

                Keyboard.Backspace();
                WaitForCurrentParameter(session);
                Assert.AreEqual("b", session.SelectedSignature.CurrentParameter.Name);
            }
        }
Esempio n. 9
0
        public void SignaturesTest()
        {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Signatures.sln");

                var item   = project.ProjectItems.Item("sigs.py");
                var window = item.Open();
                window.Activate();

                var doc = app.GetDocument(item.Document.FullName);

                doc.SetFocus();

                ((UIElement)doc.TextView).Dispatcher.Invoke((Action)(() => {
                    doc.TextView.Caret.MoveTo(new SnapshotPoint(doc.TextView.TextBuffer.CurrentSnapshot, doc.TextView.TextBuffer.CurrentSnapshot.Length));
                    ((UIElement)doc.TextView).Focus();
                }));

                Keyboard.Type("f(");

                using (var sh = doc.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("a", session.SelectedSignature.CurrentParameter.Name);

                    Keyboard.Type("b=");

                    WaitForCurrentParameter(session, "b");
                    Assert.AreEqual("b", session.SelectedSignature.CurrentParameter.Name);
                    window.Activate();

                    Keyboard.Type("42,");

                    WaitForNoCurrentParameter(session);
                    Assert.AreEqual(null, session.SelectedSignature.CurrentParameter);

                    Keyboard.Backspace();
                    WaitForCurrentParameter(session);
                    Assert.AreEqual("b", session.SelectedSignature.CurrentParameter.Name);
                }
            }
        }
Esempio n. 10
0
        public void JSDocTest()
        {
            var project = Project("JSDocTest",
                                  Compile("app", @"
/** Documentation for f.
  * 
  * Just a paragraph. It shouldn't show up anywhere.
  *
  * @param [x.y] Doesn't match any parameter in the list.
  * @param  a   Documentation for a.
  * 
  * Another paragraph that won't show up anywhere. This one has a {@link}.
  *
  * @arg    b   Documentation for b.
  *             It spans multiple lines.
  * @param  c   Documentation for c. It has a {@link} in it.
  * @arg   [d]  Documentation for d. It is an optional parameter.
  * @arg {string} [x.y] This does not match any declared parameter and should not show up anywhere.
  * @argument {number} [e=123]
  * Documentation for e. It has a default value and a type.
  *
  * @see Not a parameter!
  */
function f(a, b, c, d, e) {}

/** Documentation for g. */
var g = function() {}

var h;
/** Documentation for h. */
h = function() {}
                ")
                                  );

            using (var solution = project.Generate().ToVs()) {
                var editor = solution.OpenItem("JSDocTest", "app.js");

                // Go to end of file
                Keyboard.PressAndRelease(Key.End, Key.LeftCtrl);

                // function f()
                Keyboard.Type("f(");
                using (var sh = editor.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("Documentation for f.\r\n...", session.SelectedSignature.Documentation);
                }
                Keyboard.Backspace();
                Keyboard.Backspace();

                // var g = function()
                Keyboard.Type("g(");
                using (var sh = editor.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("Documentation for g.", session.SelectedSignature.Documentation);
                }
                Keyboard.Backspace();
                Keyboard.Backspace();

                // h = function()
                Keyboard.Type("h(");
                using (var sh = editor.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("Documentation for h.", session.SelectedSignature.Documentation);
                }
                Keyboard.Backspace();
                Keyboard.Backspace();

                // @param parsing
                Keyboard.Type("f(");
                using (var sh = editor.WaitForSession <ISignatureHelpSession>()) {
                    var session = sh.Session;
                    Assert.AreEqual("f(a, b, c, d?, e?: number = 123)", session.SelectedSignature.Content);

                    Keyboard.Type("a");
                    Assert.AreEqual("a", session.SelectedSignature.CurrentParameter.Name);
                    Assert.AreEqual("Documentation for a.", session.SelectedSignature.CurrentParameter.Documentation);

                    Keyboard.Type(", b");
                    Assert.AreEqual("b", session.SelectedSignature.CurrentParameter.Name);
                    Assert.AreEqual("Documentation for b. It spans multiple lines.", session.SelectedSignature.CurrentParameter.Documentation);

                    Keyboard.Type(", c");
                    Assert.AreEqual("c", session.SelectedSignature.CurrentParameter.Name);
                    Assert.AreEqual("Documentation for c. It has a {@link} in it.", session.SelectedSignature.CurrentParameter.Documentation);

                    Keyboard.Type(", d");
                    Assert.AreEqual("d", session.SelectedSignature.CurrentParameter.Name);
                    Assert.AreEqual("Documentation for d. It is an optional parameter.", session.SelectedSignature.CurrentParameter.Documentation);

                    Keyboard.Type(", e");
                    Assert.AreEqual("e", session.SelectedSignature.CurrentParameter.Name);
                    Assert.AreEqual("Documentation for e. It has a default value and a type.", session.SelectedSignature.CurrentParameter.Documentation);
                }
                Keyboard.Backspace();
                Keyboard.Backspace();
            }
        }
Esempio n. 11
0
    void ReceiveMessage(NetworkMessage netMsg)
    {
        //Debug.Log(message);
        var    m   = netMsg.ReadMessage <MyMessage>();
        string msg = m.msg;

        switch (m.tag)
        {
        case "Hide":
            connectWindow.SetActive(false);
            debugInfo.SetVisibility(false);
            break;

        case "TouchScreen Keyboard Width":
            if (msg == "+")
            {
                keyboard.ZoomIn(true);
            }
            else if (msg == "-")
            {
                keyboard.ZoomOut(true);
            }
            break;

        case "TouchScreen Keyboard Height":
            if (msg == "+")
            {
                keyboard.ZoomIn(false);
            }
            else if (msg == "-")
            {
                keyboard.ZoomOut(false);
            }
            break;

        case "TouchScreen Keyboard Size":
            if (msg == "+")
            {
                keyboard.ZoomIn(false, true);
            }
            else if (msg == "-")
            {
                keyboard.ZoomOut(false, true);
            }
            break;

        case "Get Keyboard Size":
            keyboard.SendSizeMsg();
            break;

        case "Candidates":
            keyboard.SetCandidates(msg.Split(','));
            break;

        case "Study1 New Phrase":
            keyboard.NewDataFile(msg, 1);
            break;

        case "Study2 New Phrase":
            keyboard.NewDataFile(msg, 2);
            break;

        case "Study1 End Phrase":
        case "Study2 End Phrase":
            keyboard.EndDataFile(msg);
            break;

        case "Accept":
            keyboard.Accept(msg);
            break;

        case "SingleKey":
            keyboard.SingleKey(msg);
            break;

        case "Cancel":
            keyboard.Cancel();
            break;

        case "Delete":
            keyboard.Delete(msg);
            break;

        case "Expand":
            keyboard.Expand();
            break;

        case "Backspace":
            keyboard.Backspace();
            break;

        case "Change Ratio":
            keyboard.ChangeRatio();
            break;

        case "NextCandidatePanel":
            keyboard.NextCandidatePanel();
            break;

        default:
            Debug.Log("Unknown tag: " + tag);
            break;
        }
    }
Esempio n. 12
0
        public void Breakpoint()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                TargetInfo ti = TargetInfo.GetTargetInfo();

                // Wait for solution to load...
                for (int i = 0; i < 40 && app.Dte.Solution.Projects.Count == 0; i++)
                {
                    System.Threading.Thread.Sleep(250);
                }

                Assert.IsFalse(0 == app.Dte.Solution.Projects.Count);

                // Set platform
                foreach (SolutionConfiguration2 solConfiguration2 in app.Dte.Solution.SolutionBuild.SolutionConfigurations)
                {
                    if (String.Equals(solConfiguration2.PlatformName, ti.Plat, StringComparison.Ordinal))
                    {
                        solConfiguration2.Activate();
                        break;
                    }
                }

                // Open project properties
                var item = app.SolutionExplorerTreeView.WaitForItem(
                    "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                    app.Dte.Solution.Projects.Item(1).Name
                    );
                AutomationWrapper.Select(item);

                app.Dte.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");

                AutomationElement doc = null;
                for (int i = 0; i < 10; i++)
                {
                    doc = app.GetDocumentTab("HelloWorld");
                    if (doc != null)
                    {
                        break;
                    }
                    doc = app.GetDocumentTab("HelloWorld.njsproj");
                    if (doc != null)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }

                Assert.IsNotNull(doc, "Failed to find project properties tab");

                // Enter IP address of target machine
                var debuggerMachineName = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_debuggerMachineName")
                    );
                debuggerMachineName.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type(ti.IP);
                app.Dte.ExecuteCommand("File.SaveAll");

                // Build project
                app.Dte.Solution.SolutionBuild.Build(true);

                // Add breakpoint
                app.Dte.Debugger.Breakpoints.Add(String.Empty, "server.js", 3, 1, String.Empty,
                                                 dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, String.Empty,
                                                 String.Empty, 1, String.Empty, 1, dbgHitCountType.dbgHitCountTypeNone);

                // F5
                app.Dte.ExecuteCommand("Debug.Start");

                // Check that breakpoint is hit
                app.WaitForMode(dbgDebugMode.dbgBreakMode, 120);
                Assert.IsTrue(app.Dte.ActiveDocument.Name.Contains("server.js"));
                Assert.IsTrue((app.Dte.ActiveDocument.Object("TextDocument") as TextDocument).Selection.ActivePoint.Line == 3);
            }
        }
Esempio n. 13
0
 public void Redo()
 {
     HighLight(-1000);
     keyboard.Backspace();
 }
Esempio n. 14
0
        /// <summary>
        /// Tries to log in.
        /// </summary>
        /// <returns>true if login is successful, false if login fails</returns>
        protected bool LogIn()
        {
            Point?clickLocation;
            Point loginOffset = Screen.LoginScreenOffset();

            //log in at the login screen
            if (!Screen.IsWelcomeScreen(out clickLocation))
            {
                if (!SelectLoginWorld(RunParams.LoginWorld, loginOffset))
                {
                    return(false);
                }

                //Click existing account. Clicks in a dead space if we are already on the login screen.
                LeftClick(Screen.Center.X + 16 + loginOffset.X, 288 + loginOffset.Y);

                if (RunParams.LoginWorld > 0)
                {
                    LeftClick(Screen.Center.X - 78 + loginOffset.X, 320 + loginOffset.Y);
                    SafeWait(500);
                }

                //fill in login
                LeftClick(Screen.Center.X + 137 + loginOffset.X, 249 + loginOffset.Y);
                Keyboard.Backspace(350);
                Keyboard.WriteLine(RunParams.Login);

                //fill in password
                Keyboard.Tab();
                Keyboard.Backspace(20);
                Keyboard.WriteLine(RunParams.Password);

                //trigger the login button
                Keyboard.Enter();
                if (SafeWait(5000))
                {
                    return(false);
                }
            }

            if (!PvPWorldSet())
            {
                //click the "CLICK HERE TO PLAY" button on the welcome screen
                if (Screen.ConfirmWelcomeScreen(out clickLocation))
                {
                    LeftClick(clickLocation.Value.X, clickLocation.Value.Y);
                }
                else
                {
                    return(false);
                }
            }

            //verify the log in
            if (Screen.ConfirmLogin())
            {
                DefaultCamera();
                ChatBox();
                return(true);
            }
            else
            {
                return(false);
            }
        }