Ejemplo n.º 1
0
        private static string SavePerfFile(string saveDirectory, VisualStudioApp app, IntPtr? dialog = null) {
            string destName;
            using (var saveDialog = new SaveDialog(app, AutomationElement.FromHandle(dialog ?? app.WaitForDialog()))) {
                var originalDestName = Path.Combine(saveDirectory, Path.GetFileName(saveDialog.FileName));
                destName = originalDestName;

                while (File.Exists(destName)) {
                    destName = string.Format("{0} {1}{2}",
                        Path.GetFileNameWithoutExtension(originalDestName),
                        Guid.NewGuid(),
                        Path.GetExtension(originalDestName)
                    );
                }

                saveDialog.FileName = destName;
                saveDialog.Save();
            }
            return destName;
        }
Ejemplo n.º 2
0
 public SaveDialog SaveAs()
 {
     return(SaveDialog.FromDte(this));
 }
Ejemplo n.º 3
0
        private IPythonProfileSession LaunchSession(
            PythonVisualStudioApp app,
            Func<IPythonProfileSession> creator
        ) {
            // Ensure the performance window has been opened, which will make
            // the app clean up all sessions when it is disposed.
            app.OpenPythonPerformance();

            IPythonProfileSession session = null;
            var task = Task.Factory.StartNew(() => {
                session = creator();
                // Must fault the task to abort the wait
                throw new Exception();
            });
            var dialog = app.WaitForDialog(task);
            if (dialog != IntPtr.Zero) {
                using (var saveDialog = new SaveDialog(app, AutomationElement.FromHandle(dialog))) {

                    var originalDestName = Path.Combine(SaveDirectory, Path.GetFileName(saveDialog.FileName));
                    var destName = originalDestName;

                    while (File.Exists(destName)) {
                        destName = string.Format("{0} {1}{2}",
                            Path.GetFileNameWithoutExtension(originalDestName),
                            Guid.NewGuid(),
                            Path.GetExtension(originalDestName)
                        );
                    }

                    saveDialog.FileName = destName;
                    saveDialog.Save();
                    try {
                        task.Wait(TimeSpan.FromSeconds(5.0));
                        Assert.Fail("Task did not fault");
                    } catch (AggregateException) {
                    }
                }
            } else {
                // Ensure the exception is observed
                var ex = task.Exception;
            }
            Assert.IsNotNull(session, "Session was not correctly initialized");
            return session;
        }