| OLD | NEW |
| 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 Loading... |
| 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">The main Visual Studio interface.</param> |
| 141 /// <param name="addInName">The name of the add-in to check if loaded.</para
m> |
| 142 public static void AssertAddinLoaded(DTE2 dte, string addInName) |
| 143 { |
| 144 bool found = false; |
| 145 foreach (AddIn addin in dte.AddIns) |
| 146 { |
| 147 if (addin.Connected && addInName.Equals(addin.Name)) |
| 148 { |
| 149 found = true; |
| 150 break; |
| 151 } |
| 152 } |
| 153 |
| 154 Assert.IsTrue(found, "Add-in is not configured to load on start."); |
| 155 } |
| 156 |
| 157 /// <summary> |
| 133 /// This returns the text contained in the given output window pane. | 158 /// This returns the text contained in the given output window pane. |
| 134 /// </summary> | 159 /// </summary> |
| 135 /// <param name="pane">Pane to get text from.</param> | 160 /// <param name="pane">Pane to get text from.</param> |
| 136 /// <returns>Text in the window.</returns> | 161 /// <returns>Text in the window.</returns> |
| 137 public static string GetPaneText(OutputWindowPane pane) | 162 public static string GetPaneText(OutputWindowPane pane) |
| 138 { | 163 { |
| 139 TextSelection selection = pane.TextDocument.Selection; | 164 TextSelection selection = pane.TextDocument.Selection; |
| 140 selection.StartOfDocument(false); | 165 selection.StartOfDocument(false); |
| 141 selection.EndOfDocument(true); | 166 selection.EndOfDocument(true); |
| 142 return selection.Text; | 167 return selection.Text; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 expectedValue, | 355 expectedValue, |
| 331 propertyValue, | 356 propertyValue, |
| 332 pageName, | 357 pageName, |
| 333 propertyName, | 358 propertyName, |
| 334 configuration.ConfigurationName); | 359 configuration.ConfigurationName); |
| 335 | 360 |
| 336 Assert.IsTrue(propertyValue.Contains(expectedValue, caseSensitive), messag
e); | 361 Assert.IsTrue(propertyValue.Contains(expectedValue, caseSensitive), messag
e); |
| 337 } | 362 } |
| 338 | 363 |
| 339 /// <summary> | 364 /// <summary> |
| 365 /// Tests that a given property is not null or empty. |
| 366 /// </summary> |
| 367 /// <param name="configuration">Gives the platform and configuration type</p
aram> |
| 368 /// <param name="pageName">Property page name where property resides.</param
> |
| 369 /// <param name="propertyName">Name of the property to check.</param> |
| 370 public static void AssertPropertyIsNotNullOrEmpty( |
| 371 VCConfiguration configuration, |
| 372 string pageName, |
| 373 string propertyName) |
| 374 { |
| 375 IVCRulePropertyStorage rule = configuration.Rules.Item(pageName); |
| 376 string propertyValue = rule.GetUnevaluatedPropertyValue(propertyName); |
| 377 |
| 378 string message = string.Format( |
| 379 "{0} was null or empty. Page: {1}, Configuration: {2}", |
| 380 propertyName, |
| 381 pageName, |
| 382 configuration.ConfigurationName); |
| 383 |
| 384 Assert.IsFalse(string.IsNullOrEmpty(propertyValue), message); |
| 385 } |
| 386 |
| 387 /// <summary> |
| 340 /// Extends the string class to allow checking if a string contains another
string | 388 /// Extends the string class to allow checking if a string contains another
string |
| 341 /// allowing a comparison type (such as case-insensitivity). | 389 /// allowing a comparison type (such as case-insensitivity). |
| 342 /// </summary> | 390 /// </summary> |
| 343 /// <param name="source">Base string to search.</param> | 391 /// <param name="source">Base string to search.</param> |
| 344 /// <param name="toCheck">String to check if contained within base string.</
param> | 392 /// <param name="toCheck">String to check if contained within base string.</
param> |
| 345 /// <param name="comparison">Comparison type.</param> | 393 /// <param name="comparison">Comparison type.</param> |
| 346 /// <returns>True if toCheck is contained in source.</returns> | 394 /// <returns>True if toCheck is contained in source.</returns> |
| 347 public static bool Contains(this string source, string toCheck, StringCompar
ison comparison) | 395 public static bool Contains(this string source, string toCheck, StringCompar
ison comparison) |
| 348 { | 396 { |
| 349 return source.IndexOf(toCheck, comparison) != -1; | 397 return source.IndexOf(toCheck, comparison) != -1; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 376 } | 424 } |
| 377 | 425 |
| 378 foreach (DirectoryInfo subdir in dir.GetDirectories()) | 426 foreach (DirectoryInfo subdir in dir.GetDirectories()) |
| 379 { | 427 { |
| 380 string path = Path.Combine(dest, subdir.Name); | 428 string path = Path.Combine(dest, subdir.Name); |
| 381 CopyDirectory(subdir.FullName, path); | 429 CopyDirectory(subdir.FullName, path); |
| 382 } | 430 } |
| 383 } | 431 } |
| 384 } | 432 } |
| 385 } | 433 } |
| OLD | NEW |