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.IO; | 8 using System.IO; |
9 | 9 |
10 using EnvDTE; | 10 using EnvDTE; |
11 using EnvDTE80; | 11 using EnvDTE80; |
12 using Microsoft.VisualStudio.TestTools.UnitTesting; | 12 using Microsoft.VisualStudio.TestTools.UnitTesting; |
13 | 13 |
14 using NativeClientVSAddIn; | 14 using NativeClientVSAddIn; |
15 | 15 |
16 /// <summary> | 16 /// <summary> |
17 /// This is a test class for PropertyManagerTest and is intended | 17 /// This is a test class for PropertyManagerTest and is intended |
18 /// to contain all PropertyManager Unit Tests | 18 /// to contain all PropertyManager Unit Tests |
19 /// </summary> | 19 /// </summary> |
20 [TestClass] | 20 [TestClass] |
21 public class PropertyManagerTest | 21 public class PropertyManagerTest |
22 { | 22 { |
23 /// <summary> | 23 /// <summary> |
24 /// This holds the path to the NaCl solution used in these tests. | 24 /// This holds the path to the NaCl solution used in these tests. |
25 /// The NaCl solution is a valid nacl/pepper plug-in VS solution. | 25 /// The NaCl solution is a valid NaCl/pepper plug-in VS solution. |
26 /// It is copied into the testing deployment directory and opened in some te
sts. | 26 /// It is copied into the testing deployment directory and opened in some te
sts. |
27 /// Because unit-tests run in any order, the solution should not be written
to | 27 /// Because unit-tests run in any order, the solution should not be written
to |
28 /// in any tests. | 28 /// in any tests. |
29 /// </summary> | 29 /// </summary> |
30 private static string naclSolution; | 30 private static string naclSolution; |
31 | 31 |
32 /// <summary> | 32 /// <summary> |
33 /// The main visual studio object. | 33 /// The main visual studio object. |
34 /// </summary> | 34 /// </summary> |
35 private DTE2 dte_; | 35 private DTE2 dte_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 target.ProjectPlatform, | 122 target.ProjectPlatform, |
123 "SetTarget did not succeed with nacl platform on valid project."); | 123 "SetTarget did not succeed with nacl platform on valid project."); |
124 Assert.AreEqual(expectedSDKRootDir, target.SDKRootDirectory, "SDK Root inc
orrect."); | 124 Assert.AreEqual(expectedSDKRootDir, target.SDKRootDirectory, "SDK Root inc
orrect."); |
125 | 125 |
126 target.SetTarget(naclProject, "Win32", "Debug"); | 126 target.SetTarget(naclProject, "Win32", "Debug"); |
127 Assert.AreEqual( | 127 Assert.AreEqual( |
128 PropertyManager.ProjectPlatformType.Other, | 128 PropertyManager.ProjectPlatformType.Other, |
129 target.ProjectPlatform, | 129 target.ProjectPlatform, |
130 "SetTarget did not set 'other' platform on when Win32 platform of vali
d project."); | 130 "SetTarget did not set 'other' platform on when Win32 platform of vali
d project."); |
131 | 131 |
| 132 target.SetTarget(naclProject, Strings.PNaClPlatformName, "Debug"); |
| 133 Assert.AreEqual( |
| 134 PropertyManager.ProjectPlatformType.NaCl, |
| 135 target.ProjectPlatform, |
| 136 "SetTarget did not succeed with nacl platform on valid project."); |
| 137 Assert.AreEqual(expectedSDKRootDir, target.SDKRootDirectory, "SDK Root inc
orrect."); |
| 138 |
132 target.SetTarget(naclProject, Strings.PepperPlatformName, "Debug"); | 139 target.SetTarget(naclProject, Strings.PepperPlatformName, "Debug"); |
133 Assert.AreEqual( | 140 Assert.AreEqual( |
134 PropertyManager.ProjectPlatformType.Pepper, | 141 PropertyManager.ProjectPlatformType.Pepper, |
135 target.ProjectPlatform, | 142 target.ProjectPlatform, |
136 "SetTarget did not succeed with pepper platform on valid project."); | 143 "SetTarget did not succeed with pepper platform on valid project."); |
137 Assert.AreEqual(expectedSDKRootDir, target.SDKRootDirectory, "SDK Root inc
orrect."); | 144 Assert.AreEqual(expectedSDKRootDir, target.SDKRootDirectory, "SDK Root inc
orrect."); |
138 | 145 |
139 // Setting the start-up project to a non-cpp project should make loading f
ail. | 146 // Setting the start-up project to a non-cpp project should make loading f
ail. |
140 object[] badStartupProj = { TestUtilities.NotNaClProjectUniqueName }; | 147 object[] badStartupProj = { TestUtilities.NotNaClProjectUniqueName }; |
141 dte_.Solution.SolutionBuild.StartupProjects = badStartupProj; | 148 dte_.Solution.SolutionBuild.StartupProjects = badStartupProj; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 Assert.AreEqual(projectDir, target.ProjectDirectory, "ProjectDirectory."); | 206 Assert.AreEqual(projectDir, target.ProjectDirectory, "ProjectDirectory."); |
200 Assert.AreEqual(outputDir, target.OutputDirectory, "OutputDirectory."); | 207 Assert.AreEqual(outputDir, target.OutputDirectory, "OutputDirectory."); |
201 Assert.AreEqual(assembly, target.PluginAssembly, "PluginAssembly."); | 208 Assert.AreEqual(assembly, target.PluginAssembly, "PluginAssembly."); |
202 Assert.AreEqual( | 209 Assert.AreEqual( |
203 @"newlib", | 210 @"newlib", |
204 target.GetProperty("ConfigurationGeneral", "ToolchainName"), | 211 target.GetProperty("ConfigurationGeneral", "ToolchainName"), |
205 "GetProperty() with ToolchainName incorrect."); | 212 "GetProperty() with ToolchainName incorrect."); |
206 } | 213 } |
207 | 214 |
208 /// <summary> | 215 /// <summary> |
| 216 /// A test for GetProperty. Checks some non-trivial C# properties and the Ge
tProperty method. |
| 217 /// </summary> |
| 218 [TestMethod] |
| 219 public void GetPropertyPNaClTest() |
| 220 { |
| 221 string expectedSDKRootDir = |
| 222 Environment.GetEnvironmentVariable(Strings.SDKPathEnvironmentVariabl
e); |
| 223 Assert.IsNotNull(expectedSDKRootDir, "SDK Path environment variable not
set!"); |
| 224 expectedSDKRootDir = expectedSDKRootDir.TrimEnd(new char[] { '/', '\\' }
); |
| 225 |
| 226 // Set up the property manager to read the NaCl platform settings from B
lankValidSolution. |
| 227 PropertyManager target = new PropertyManager(); |
| 228 dte_.Solution.Open(naclSolution); |
| 229 Project naclProject = dte_.Solution.Projects.Item(TestUtilities.BlankNaC
lProjectUniqueName); |
| 230 target.SetTarget(naclProject, Strings.PNaClPlatformName, "Debug"); |
| 231 Assert.AreEqual( |
| 232 PropertyManager.ProjectPlatformType.NaCl, |
| 233 target.ProjectPlatform, |
| 234 "SetTarget did not succeed with nacl platform on valid project."); |
| 235 |
| 236 string slnDir = Path.GetDirectoryName(naclSolution); |
| 237 string projectDir = Path.Combine( |
| 238 slnDir, Path.GetDirectoryName(TestUtilities.BlankNaClProjectUniqueNa
me)) + @"\"; |
| 239 string outputDir = Path.Combine(projectDir, "PNaCl", "newlib", "Debug")
+ @"\"; |
| 240 string assembly = Path.Combine(outputDir, TestUtilities.BlankNaClProject
Name + ".pexe"); |
| 241 |
| 242 Assert.AreEqual(expectedSDKRootDir, target.SDKRootDirectory, "SDK Root."
); |
| 243 Assert.AreEqual(projectDir, target.ProjectDirectory, "ProjectDirectory."
); |
| 244 Assert.AreEqual(outputDir, target.OutputDirectory, "OutputDirectory."); |
| 245 Assert.AreEqual(assembly, target.PluginAssembly, "PluginAssembly."); |
| 246 Assert.AreEqual( |
| 247 @"newlib", |
| 248 target.GetProperty("ConfigurationGeneral", "ToolchainName"), |
| 249 "GetProperty() with ToolchainName incorrect."); |
| 250 } |
| 251 |
| 252 /// <summary> |
209 /// A test for SetProperty. | 253 /// A test for SetProperty. |
210 /// </summary> | 254 /// </summary> |
211 [TestMethod] | 255 [TestMethod] |
212 public void SetPropertyTest() | 256 public void SetPropertyTest() |
213 { | 257 { |
214 string setTargetSolution = TestUtilities.CreateBlankValidNaClSolution( | 258 string setTargetSolution = TestUtilities.CreateBlankValidNaClSolution( |
215 dte_, | 259 dte_, |
216 "PropertyManagerTestSetTarget", | 260 "PropertyManagerTestSetTarget", |
217 NativeClientVSAddIn.Strings.NaCl64PlatformName, | 261 NativeClientVSAddIn.Strings.NaCl64PlatformName, |
218 NativeClientVSAddIn.Strings.NaCl64PlatformName, | 262 NativeClientVSAddIn.Strings.NaCl64PlatformName, |
(...skipping 11 matching lines...) Expand all Loading... |
230 | 274 |
231 string newValue = "ThisIsNew"; | 275 string newValue = "ThisIsNew"; |
232 target.SetProperty("ConfigurationGeneral", "VSNaClSDKRoot", newValue); | 276 target.SetProperty("ConfigurationGeneral", "VSNaClSDKRoot", newValue); |
233 Assert.AreEqual( | 277 Assert.AreEqual( |
234 newValue, | 278 newValue, |
235 target.GetProperty("ConfigurationGeneral", "VSNaClSDKRoot"), | 279 target.GetProperty("ConfigurationGeneral", "VSNaClSDKRoot"), |
236 "SetProperty() did not set property VSNaClSDKRoot."); | 280 "SetProperty() did not set property VSNaClSDKRoot."); |
237 } | 281 } |
238 } | 282 } |
239 } | 283 } |
OLD | NEW |