示例#1
0
    /// <summary>
    /// Called when Visual Studio ends a debugging session.
    /// Shuts down the web server and debugger.
    /// </summary>
    /// <param name="reason">The parameter is not used.</param>
    private void DebuggerOnEnterDesignMode(dbgEventReason reason)
    {
      if (debugger_ != null)
      {
        debugger_.Dispose();
        debugger_ = null;
      }

      if (webServer_ != null)
      {
        webServer_.Dispose();
        webServer_ = null;
      }
    }
示例#2
0
 /// <summary>
 /// Called when Visual Studio starts a debugging session.
 /// Here we kick off the debugger and web server if appropriate.
 /// </summary>
 /// <param name="reason">Indicates how we are entering run mode (breakpoint or launch).</param>
 private void DebuggerOnEnterRunMode(dbgEventReason reason)
 {
   // If we are starting debugging (not re-entering from a breakpoint)
   // then load project settings and start the debugger-helper.
   if (reason == dbgEventReason.dbgEventReasonLaunchProgram)
   {
     PropertyManager properties = new PropertyManager();
     properties.SetTargetToActive(dte_);
     if (properties.PlatformType == PropertyManager.ProjectPlatformType.NaCl)
     {
       debugger_ = new PluginDebuggerGDB(dte_, properties);
       webServer_ = new WebServer(webServerOutputPane_, properties);
     }
     else if (properties.PlatformType == PropertyManager.ProjectPlatformType.Pepper)
     {
       debugger_ = new PluginDebuggerVS(dte_, properties);
       webServer_ = new WebServer(webServerOutputPane_, properties);
     }
   }
 }
示例#3
0
    public void WebServerConstructorTest()
    {
      OutputWindowPane outputWindowPane = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Add(
          Strings.WebServerOutputWindowTitle);

      // Set up mock property manager to return the desired property values.
      MockPropertyManager properties = new MockPropertyManager(
        PropertyManager.ProjectPlatformType.Pepper,
        delegate(string page, string name)
        {
          switch (page)
          {
            case "ConfigurationGeneral":
              switch (name)
              {
                case "VSNaClSDKRoot": return System.Environment.GetEnvironmentVariable(
                    NativeClientVSAddIn.Strings.SDKPathEnvironmentVariable);
                case "NaClWebServerPort": return "5105";
              }

              break;
            case "Property":
              switch (name)
              {
                case "ProjectDirectory": return TestContext.DeploymentDirectory;
              }

              break;
          }

          return null;
        },
        null);

      WebServer target = null;
      try
      {
        target = new WebServer(outputWindowPane, properties);

        TestUtilities.AssertTrueWithTimeout(
          () => !string.IsNullOrEmpty(TestUtilities.GetPaneText(outputWindowPane)),
          TimeSpan.FromMilliseconds(500),
          20,
          "Pane text never appeared");

        TestUtilities.AssertTrueWithTimeout(
            () => TestUtilities.DoesProcessExist("python.exe", "5105", "httpd.py"),
            TimeSpan.FromMilliseconds(500),
            20,
            "Web server failed to start.");

        target.Dispose();

        TestUtilities.AssertTrueWithTimeout(
            () => !TestUtilities.DoesProcessExist("python.exe", "5105", "httpd.py"),
            TimeSpan.FromMilliseconds(500),
            20,
            "Web server failed to shut down.");
      }
      finally
      {
        if (target != null)
        {
          target.Dispose();
        }
      }
    }