OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
binji
2013/02/12 00:45:27
apparently, this is not necessary.
Sam Clegg
2013/02/12 01:02:15
But this is a "new" file.
binji
2013/02/12 01:19:05
Ah, fair enough.
| |
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 using System; | 4 using System; |
5 using System.Text; | 5 using System.Text; |
6 using System.Collections.Generic; | 6 using System.Collections.Generic; |
7 using EnvDTE; | 7 using EnvDTE; |
8 using EnvDTE80; | 8 using EnvDTE80; |
9 using Microsoft.VisualStudio.TestTools.UnitTesting; | 9 using Microsoft.VisualStudio.TestTools.UnitTesting; |
10 using Microsoft.VisualStudio.VCProjectEngine; | 10 using Microsoft.VisualStudio.VCProjectEngine; |
11 using NaCl.Build.CPPTasks; | 11 using NaCl.Build.CPPTasks; |
12 using NativeClientVSAddIn; | 12 using NativeClientVSAddIn; |
13 | 13 |
14 namespace UnitTests | 14 namespace UnitTests |
15 { | 15 { |
16 [TestClass] | 16 [TestClass] |
17 public class CompileTest | 17 public class BaseCompileTest |
18 { | 18 { |
19 /// <summary> | 19 /// <summary> |
20 /// The main visual studio object. | 20 /// The main visual studio object. |
21 /// </summary> | 21 /// </summary> |
22 private DTE2 dte_; | 22 protected DTE2 dte_; |
23 | 23 |
24 /// <summary> | 24 /// <summary> |
25 /// The path to a NaCl solution used in compile tests. | 25 /// The path to a NaCl solution used in compile tests. |
26 /// </summary> | 26 /// </summary> |
27 private static string SolutionName_; | 27 protected static string SolutionName_; |
28 | 28 |
29 /// <summary> | 29 /// <summary> |
30 /// This is run one time before any test methods are called. Here we set -up test-copies of | 30 /// This is run one time before any test methods are called. Here we set -up test-copies of |
31 /// new NaCl solutions for use in the tests. | 31 /// new NaCl solutions for use in the tests. |
32 /// </summary> | 32 /// </summary> |
33 /// <param name="testContext">Holds information about the current test r un</param> | 33 /// <param name="testContext">Holds information about the current test r un</param> |
34 [ClassInitialize] | 34 public static void ClassSetUp(TestContext testContext, string solutionBa seName) |
35 public static void ClassSetUp(TestContext testContext) | |
36 { | 35 { |
37 DTE2 dte = TestUtilities.StartVisualStudioInstance(); | 36 DTE2 dte = TestUtilities.StartVisualStudioInstance(); |
38 try | 37 try |
39 { | 38 { |
40 SolutionName_ = TestUtilities.CreateBlankValidNaClSolution( | 39 SolutionName_ = TestUtilities.CreateBlankValidNaClSolution( |
41 dte, | 40 dte, |
42 "CompileTest", | 41 solutionBaseName, |
43 Strings.PepperPlatformName, | 42 Strings.PepperPlatformName, |
44 Strings.NaCl64PlatformName, | 43 Strings.NaCl64PlatformName, |
45 testContext); | 44 testContext); |
46 } | 45 } |
47 finally | 46 finally |
48 { | 47 { |
49 TestUtilities.CleanUpVisualStudioInstance(dte); | 48 TestUtilities.CleanUpVisualStudioInstance(dte); |
50 } | 49 } |
51 } | 50 } |
52 | 51 |
53 /// <summary> | 52 /// <summary> |
54 /// This is run after each test to clean up things created in TestSetup( ). | |
55 /// </summary> | |
56 [TestCleanup] | |
57 public void ClassTearDown() | |
58 { | |
59 TestUtilities.CleanUpVisualStudioInstance(dte_); | |
60 } | |
61 | |
62 /// <summary> | |
63 /// This is run before each test to create test resources. | 53 /// This is run before each test to create test resources. |
64 /// </summary> | 54 /// </summary> |
65 [TestInitialize] | 55 [TestInitialize] |
66 public void TestSetup() | 56 public void TestSetup() |
67 { | 57 { |
68 dte_ = TestUtilities.StartVisualStudioInstance(); | 58 dte_ = TestUtilities.StartVisualStudioInstance(); |
69 try | 59 try |
70 { | 60 { |
71 TestUtilities.AssertAddinLoaded(dte_, Strings.AddInName); | 61 TestUtilities.AssertAddinLoaded(dte_, Strings.AddInName); |
72 } | 62 } |
(...skipping 13 matching lines...) Expand all Loading... | |
86 /// <param name="platformName">Platform name.</param> | 76 /// <param name="platformName">Platform name.</param> |
87 private void TryCompile(string configName, string platformName) | 77 private void TryCompile(string configName, string platformName) |
88 { | 78 { |
89 string failFormat = "Project compile failed for {0} platform {1} con fig." | 79 string failFormat = "Project compile failed for {0} platform {1} con fig." |
90 + "Build output: {2}"; | 80 + "Build output: {2}"; |
91 string cygwinWarningFormat = "Did not pass cygwin nodosfilewarning e nvironment var to" | 81 string cygwinWarningFormat = "Did not pass cygwin nodosfilewarning e nvironment var to" |
92 + " tools Platform: {0}, configuration: { 1}"; | 82 + " tools Platform: {0}, configuration: { 1}"; |
93 StringComparison ignoreCase = StringComparison.InvariantCultureIgnor eCase; | 83 StringComparison ignoreCase = StringComparison.InvariantCultureIgnor eCase; |
94 | 84 |
95 // Open Debug configuration and build. | 85 // Open Debug configuration and build. |
96 dte_.Solution.Open(SolutionName_); | |
binji
2013/02/12 00:45:27
not needed?
Sam Clegg
2013/02/12 01:03:40
These tests we opening an closing the project way
| |
97 TestUtilities.SetSolutionConfiguration( | 86 TestUtilities.SetSolutionConfiguration( |
98 dte_, TestUtilities.NaClProjectUniqueName, configName, platformN ame); | 87 dte_, TestUtilities.NaClProjectUniqueName, configName, platformN ame); |
99 dte_.Solution.SolutionBuild.Build(true); | 88 dte_.Solution.SolutionBuild.Build(true); |
100 | 89 |
101 string compileOutput = TestUtilities.GetPaneText( | 90 string compileOutput = TestUtilities.GetPaneText( |
102 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build")); | 91 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build")); |
103 Assert.IsTrue( | 92 Assert.IsTrue( |
104 compileOutput.Contains("Build succeeded.", ignoreCase), | 93 compileOutput.Contains("Build succeeded.", ignoreCase), |
105 string.Format(failFormat, platformName, configName, compileOutpu t)); | 94 string.Format(failFormat, platformName, configName, compileOutpu t)); |
106 Assert.IsFalse( | 95 Assert.IsFalse( |
107 compileOutput.Contains("MS-DOS style path detected", ignoreCase) , | 96 compileOutput.Contains("MS-DOS style path detected", ignoreCase) , |
108 string.Format(cygwinWarningFormat, platformName, configName)); | 97 string.Format(cygwinWarningFormat, platformName, configName)); |
109 | |
110 dte_.Solution.Close(true); | |
111 } | 98 } |
112 | 99 |
113 /// <summary> | 100 /// <summary> |
114 /// Set the type of the project: Executable, DynamicLibrary, StaticLibra ry | 101 /// Set the type of the project: Executable, DynamicLibrary, StaticLibra ry |
115 /// </summary> | 102 /// </summary> |
116 private void SetProjectType(string projectType, string platformName) | 103 private void SetProjectType(string projectType, string platformName) |
117 { | 104 { |
118 dte_.Solution.Open(SolutionName_); | |
119 Project project = dte_.Solution.Projects.Item(TestUtilities.NaClProj ectUniqueName); | 105 Project project = dte_.Solution.Projects.Item(TestUtilities.NaClProj ectUniqueName); |
120 VCConfiguration config; | 106 VCConfiguration config; |
121 IVCRulePropertyStorage rule; | 107 IVCRulePropertyStorage rule; |
122 | 108 |
123 config = TestUtilities.GetVCConfiguration(project, "Debug", platform Name); | 109 config = TestUtilities.GetVCConfiguration(project, "Debug", platform Name); |
124 rule = config.Rules.Item("ConfigurationGeneral"); | 110 rule = config.Rules.Item("ConfigurationGeneral"); |
125 rule.SetPropertyValue("ConfigurationType", projectType); | 111 rule.SetPropertyValue("ConfigurationType", projectType); |
126 | 112 |
127 config = TestUtilities.GetVCConfiguration(project, "Release", platfo rmName); | 113 config = TestUtilities.GetVCConfiguration(project, "Release", platfo rmName); |
128 rule = config.Rules.Item("ConfigurationGeneral"); | 114 rule = config.Rules.Item("ConfigurationGeneral"); |
129 rule.SetPropertyValue("ConfigurationType", projectType); | 115 rule.SetPropertyValue("ConfigurationType", projectType); |
130 dte_.Solution.Close(true); | |
131 } | 116 } |
132 | 117 |
133 /// <summary> | 118 protected void CheckCompile(string platform, bool dll) |
134 /// Test method to check that the NaCl platform compiles a test project. | |
135 /// </summary> | |
136 [TestMethod] | |
137 public void CheckNaCl64Compile() | |
138 { | 119 { |
139 CheckCompile(Strings.NaCl64PlatformName, false); | 120 dte_.Solution.Open(SolutionName_); |
140 } | |
141 | |
142 /// <summary> | |
143 /// Test method to check that the NaCl platform compiles a test project. | |
144 /// </summary> | |
145 [TestMethod] | |
146 public void CheckNaClARMCompile() | |
147 { | |
148 string root = System.Environment.GetEnvironmentVariable("NACL_SDK_RO OT"); | |
149 if (!SDKUtilities.SupportsARM(root)) | |
150 { | |
151 Assert.Inconclusive(); | |
152 } | |
153 CheckCompile(Strings.NaClARMPlatformName, false); | |
154 } | |
155 | |
156 /// <summary> | |
157 /// Test method to check that the Pepper platform compiles a test projec t. | |
158 /// </summary> | |
159 [TestMethod] | |
160 public void CheckPepperCompile() | |
161 { | |
162 CheckCompile(Strings.PepperPlatformName, true); | |
163 } | |
164 | |
165 /// <summary> | |
166 /// Test method to check that the NaCl platform compiles a test project. | |
167 /// </summary> | |
168 [TestMethod] | |
169 public void CheckPNaClCompile() | |
170 { | |
171 string root = System.Environment.GetEnvironmentVariable("NACL_SDK_RO OT"); | |
172 if (!SDKUtilities.SupportsPNaCl(root)) | |
173 { | |
174 Assert.Inconclusive(); | |
175 } | |
176 CheckCompile(Strings.PNaClPlatformName, false); | |
177 } | |
178 | |
179 private void CheckCompile(string platform, bool dll) | |
180 { | |
181 SetProjectType("Executable", platform); | 121 SetProjectType("Executable", platform); |
182 TryCompile("Debug", platform); | 122 TryCompile("Debug", platform); |
183 TryCompile("Release", platform); | 123 TryCompile("Release", platform); |
184 SetProjectType("StaticLibrary", platform); | 124 SetProjectType("StaticLibrary", platform); |
185 TryCompile("Debug", platform); | 125 TryCompile("Debug", platform); |
186 TryCompile("Release", platform); | 126 TryCompile("Release", platform); |
187 if (dll) | 127 if (dll) |
188 { | 128 { |
189 SetProjectType("DynamicLibrary", platform); | 129 SetProjectType("DynamicLibrary", platform); |
190 TryCompile("Debug", platform); | 130 TryCompile("Debug", platform); |
191 TryCompile("Release", platform); | 131 TryCompile("Release", platform); |
192 } | 132 } |
133 dte_.Solution.Close(true); | |
193 } | 134 } |
194 } | 135 } |
195 } | 136 } |
OLD | NEW |