Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs

Issue 10836143: Refactored the VS add-in (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 namespace UnitTests 5 namespace UnitTests
6 { 6 {
7 using System; 7 using System;
8 using System.Collections.Generic; 8 using System.Collections.Generic;
9 using System.IO; 9 using System.IO;
10 using System.Linq; 10 using System.Linq;
(...skipping 18 matching lines...) Expand all
29 /// Uniquename of the NaCl project in BlankValidSolution. 29 /// Uniquename of the NaCl project in BlankValidSolution.
30 /// </summary> 30 /// </summary>
31 public const string BlankNaClProjectUniqueName = @"NaClProject\NaClProject.v cxproj"; 31 public const string BlankNaClProjectUniqueName = @"NaClProject\NaClProject.v cxproj";
32 32
33 /// <summary> 33 /// <summary>
34 /// Uniquename of the non-NaCl project in BlankValidSolution. 34 /// Uniquename of the non-NaCl project in BlankValidSolution.
35 /// </summary> 35 /// </summary>
36 public const string NotNaClProjectUniqueName = @"NotNaCl\NotNaCl.csproj"; 36 public const string NotNaClProjectUniqueName = @"NotNaCl\NotNaCl.csproj";
37 37
38 /// <summary> 38 /// <summary>
39 /// A generic boolean statement to be used with RetryWithTimeout.
40 /// </summary>
41 /// <returns>True if the statement is true, false if false.</returns>
42 public delegate bool RetryStatement();
43
44 /// <summary>
39 /// This starts an instance of Visual Studio and get its DTE object. 45 /// This starts an instance of Visual Studio and get its DTE object.
40 /// </summary> 46 /// </summary>
41 /// <returns>DTE of the started instance.</returns> 47 /// <returns>DTE of the started instance.</returns>
42 public static DTE2 StartVisualStudioInstance() 48 public static DTE2 StartVisualStudioInstance()
43 { 49 {
44 // Set up filter to handle threading events and automatically retry calls 50 // Set up filter to handle threading events and automatically retry calls
45 // to dte which fail because dte is busy. 51 // to dte which fail because dte is busy.
46 ComMessageFilter.Register(); 52 ComMessageFilter.Register();
47 53
48 Type visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0"); 54 Type visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 { 154 {
149 found = true; 155 found = true;
150 break; 156 break;
151 } 157 }
152 } 158 }
153 159
154 Assert.IsTrue(found, "Add-in is not configured to load on start."); 160 Assert.IsTrue(found, "Add-in is not configured to load on start.");
155 } 161 }
156 162
157 /// <summary> 163 /// <summary>
164 /// Will retry the given statement up to maxRetry times while pausing betwee n each try for
165 /// the given interval.
166 /// </summary>
167 /// <param name="test">Generic boolean statement.</param>
168 /// <param name="interval">Amount of time to wait between each retry.</param >
169 /// <param name="maxRetry">Maximum number of retries.</param>
170 /// <param name="message">Message to print on failure.</param>
171 public static void AssertTrueWithTimeout(
172 RetryStatement test, TimeSpan interval, int maxRetry, string message)
173 {
174 for (int tryCount = 0; tryCount <= maxRetry; tryCount++)
175 {
176 if (test.Invoke())
177 {
178 return;
179 }
180
181 System.Threading.Thread.Sleep(interval);
182 }
183
184 throw new Exception(string.Format("Statement timed out. {0}", message));
185 }
186
187 /// <summary>
158 /// This returns the text contained in the given output window pane. 188 /// This returns the text contained in the given output window pane.
159 /// </summary> 189 /// </summary>
160 /// <param name="pane">Pane to get text from.</param> 190 /// <param name="pane">Pane to get text from.</param>
161 /// <returns>Text in the window.</returns> 191 /// <returns>Text in the window.</returns>
162 public static string GetPaneText(OutputWindowPane pane) 192 public static string GetPaneText(OutputWindowPane pane)
163 { 193 {
164 TextSelection selection = pane.TextDocument.Selection; 194 TextSelection selection = pane.TextDocument.Selection;
165 selection.StartOfDocument(false); 195 selection.StartOfDocument(false);
166 selection.EndOfDocument(true); 196 selection.EndOfDocument(true);
167 return selection.Text; 197 return selection.Text;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 454 }
425 455
426 foreach (DirectoryInfo subdir in dir.GetDirectories()) 456 foreach (DirectoryInfo subdir in dir.GetDirectories())
427 { 457 {
428 string path = Path.Combine(dest, subdir.Name); 458 string path = Path.Combine(dest, subdir.Name);
429 CopyDirectory(subdir.FullName, path); 459 CopyDirectory(subdir.FullName, path);
430 } 460 }
431 } 461 }
432 } 462 }
433 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698