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

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

Issue 10830151: VS Add-in more properties and improvements (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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 NativeClientVSAddIn.Strings.PepperPlatformName, pepperCopyFrom, true ); 108 NativeClientVSAddIn.Strings.PepperPlatformName, pepperCopyFrom, true );
109 } 109 }
110 else 110 else
111 { 111 {
112 proj.ConfigurationManager.AddPlatform( 112 proj.ConfigurationManager.AddPlatform(
113 NativeClientVSAddIn.Strings.PepperPlatformName, pepperCopyFrom, true ); 113 NativeClientVSAddIn.Strings.PepperPlatformName, pepperCopyFrom, true );
114 proj.ConfigurationManager.AddPlatform( 114 proj.ConfigurationManager.AddPlatform(
115 NativeClientVSAddIn.Strings.NaClPlatformName, naclCopyFrom, true); 115 NativeClientVSAddIn.Strings.NaClPlatformName, naclCopyFrom, true);
116 } 116 }
117 117
118 // Set the active solution configuration to Debug|NaCl.
119 SetSolutionConfiguration(
120 dte, BlankNaClProjectUniqueName, "Debug", NativeClientVSAddIn.String s.NaClPlatformName);
121
118 proj.Save(); 122 proj.Save();
119 dte.Solution.SaveAs(newSolution); 123 dte.Solution.SaveAs(newSolution);
120 } 124 }
121 finally 125 finally
122 { 126 {
123 if (dte.Solution != null) 127 if (dte.Solution != null)
124 { 128 {
125 dte.Solution.Close(); 129 dte.Solution.Close();
126 } 130 }
127 } 131 }
128 132
129 return newSolution; 133 return newSolution;
130 } 134 }
131 135
132 /// <summary> 136 /// <summary>
137 /// Ensures that the add-in is configured to load on start. If it isn't then some tests may
138 /// unexpectedly fail, this check helps catch that problem early.
139 /// </summary>
140 /// <param name="dte"></param>
141 public static void AssertAddinLoaded(DTE2 dte, string addInName)
142 {
143 bool found = false;
144 foreach (AddIn addin in dte.AddIns)
145 {
146 if (addin.Connected && addInName.Equals(addin.Name))
147 {
148 found = true;
149 break;
150 }
151 }
152
153 Assert.IsTrue(found, "Add-in is not configured to load on start.");
154 }
155
156 /// <summary>
133 /// This returns the text contained in the given output window pane. 157 /// This returns the text contained in the given output window pane.
134 /// </summary> 158 /// </summary>
135 /// <param name="pane">Pane to get text from.</param> 159 /// <param name="pane">Pane to get text from.</param>
136 /// <returns>Text in the window.</returns> 160 /// <returns>Text in the window.</returns>
137 public static string GetPaneText(OutputWindowPane pane) 161 public static string GetPaneText(OutputWindowPane pane)
138 { 162 {
139 TextSelection selection = pane.TextDocument.Selection; 163 TextSelection selection = pane.TextDocument.Selection;
140 selection.StartOfDocument(false); 164 selection.StartOfDocument(false);
141 selection.EndOfDocument(true); 165 selection.EndOfDocument(true);
142 return selection.Text; 166 return selection.Text;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 expectedValue, 354 expectedValue,
331 propertyValue, 355 propertyValue,
332 pageName, 356 pageName,
333 propertyName, 357 propertyName,
334 configuration.ConfigurationName); 358 configuration.ConfigurationName);
335 359
336 Assert.IsTrue(propertyValue.Contains(expectedValue, caseSensitive), messag e); 360 Assert.IsTrue(propertyValue.Contains(expectedValue, caseSensitive), messag e);
337 } 361 }
338 362
339 /// <summary> 363 /// <summary>
364 /// Tests that a given property is not null or empty.
365 /// </summary>
366 /// <param name="configuration">Gives the platform and configuration type</p aram>
367 /// <param name="pageName">Property page name where property resides.</param >
368 /// <param name="propertyName">Name of the property to check.</param>
369 public static void AssertPropertyIsNotNullOrEmpty(
370 VCConfiguration configuration,
371 string pageName,
372 string propertyName)
373 {
374 IVCRulePropertyStorage rule = configuration.Rules.Item(pageName);
375 string propertyValue = rule.GetUnevaluatedPropertyValue(propertyName);
376
377 string message = string.Format(
378 "{0} was null or empty. Page: {1}, Configuration: {2}",
379 propertyName,
380 pageName,
381 configuration.ConfigurationName);
382
383 Assert.IsFalse(string.IsNullOrEmpty(propertyValue), message);
384 }
385
386 /// <summary>
340 /// Extends the string class to allow checking if a string contains another string 387 /// Extends the string class to allow checking if a string contains another string
341 /// allowing a comparison type (such as case-insensitivity). 388 /// allowing a comparison type (such as case-insensitivity).
342 /// </summary> 389 /// </summary>
343 /// <param name="source">Base string to search.</param> 390 /// <param name="source">Base string to search.</param>
344 /// <param name="toCheck">String to check if contained within base string.</ param> 391 /// <param name="toCheck">String to check if contained within base string.</ param>
345 /// <param name="comparison">Comparison type.</param> 392 /// <param name="comparison">Comparison type.</param>
346 /// <returns>True if toCheck is contained in source.</returns> 393 /// <returns>True if toCheck is contained in source.</returns>
347 public static bool Contains(this string source, string toCheck, StringCompar ison comparison) 394 public static bool Contains(this string source, string toCheck, StringCompar ison comparison)
348 { 395 {
349 return source.IndexOf(toCheck, comparison) != -1; 396 return source.IndexOf(toCheck, comparison) != -1;
(...skipping 26 matching lines...) Expand all
376 } 423 }
377 424
378 foreach (DirectoryInfo subdir in dir.GetDirectories()) 425 foreach (DirectoryInfo subdir in dir.GetDirectories())
379 { 426 {
380 string path = Path.Combine(dest, subdir.Name); 427 string path = Path.Combine(dest, subdir.Name);
381 CopyDirectory(subdir.FullName, path); 428 CopyDirectory(subdir.FullName, path);
382 } 429 }
383 } 430 }
384 } 431 }
385 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698