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

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

Issue 14122017: [VS Addin] Add visual studio 2012 support (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 6 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 /// <summary> 45 /// <summary>
46 /// This starts an instance of Visual Studio and get its DTE object. 46 /// This starts an instance of Visual Studio and get its DTE object.
47 /// </summary> 47 /// </summary>
48 /// <returns>DTE of the started instance.</returns> 48 /// <returns>DTE of the started instance.</returns>
49 public static DTE2 StartVisualStudioInstance() 49 public static DTE2 StartVisualStudioInstance()
50 { 50 {
51 // Set up filter to handle threading events and automatically retry calls 51 // Set up filter to handle threading events and automatically retry calls
52 // to dte which fail because dte is busy. 52 // to dte which fail because dte is busy.
53 ComMessageFilter.Register(); 53 ComMessageFilter.Register();
54 54
55 Type visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0"); 55 Type visualStudioType;
56 if (IsVS2012())
57 visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.11.0");
58 else
59 visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
60
56 DTE2 visualStudio = Activator.CreateInstance(visualStudioType) as DTE2; 61 DTE2 visualStudio = Activator.CreateInstance(visualStudioType) as DTE2;
57 if (visualStudio == null) 62 if (visualStudio == null)
58 { 63 {
59 throw new Exception("Visual Studio failed to start"); 64 throw new Exception("Visual Studio failed to start");
60 } 65 }
61 66
62 visualStudio.MainWindow.Visible = true; 67 visualStudio.MainWindow.Visible = true;
63 return visualStudio; 68 return visualStudio;
64 } 69 }
65 70
(...skipping 10 matching lines...) Expand all
76 dte.Solution.Close(); 81 dte.Solution.Close();
77 } 82 }
78 83
79 dte.Quit(); 84 dte.Quit();
80 } 85 }
81 86
82 // Stop the message filter. 87 // Stop the message filter.
83 ComMessageFilter.Revoke(); 88 ComMessageFilter.Revoke();
84 } 89 }
85 90
91 public static void SetProjectType(Project project, string projectType, strin g platformName)
92 {
93 VCConfiguration config;
94 IVCRulePropertyStorage rule;
95
96 config = TestUtilities.GetVCConfiguration(project, "Debug", platformName );
97 rule = config.Rules.Item("ConfigurationGeneral");
98 rule.SetPropertyValue("ConfigurationType", projectType);
99
100 config = TestUtilities.GetVCConfiguration(project, "Release", platformNa me);
101 rule = config.Rules.Item("ConfigurationGeneral");
102 rule.SetPropertyValue("ConfigurationType", projectType);
103 }
104
105 public static bool IsVS2012()
106 {
107 #if VS2012
108 return true;
109 #else
110 return false;
111 #endif
112 }
113
114 static void AddPlatform(Project project, String platform, String copyFrom)
115 {
116 project.ConfigurationManager.AddPlatform(platform, copyFrom, true);
117 }
118
86 /// <summary> 119 /// <summary>
87 /// Creates a blank valid NaCl project with up-to-date settings. The path t o the new solution 120 /// Creates a blank valid NaCl project with up-to-date settings. The path t o the new solution
88 /// is returned. 121 /// is returned.
89 /// </summary> 122 /// </summary>
90 /// <param name="dte">Interface to an open Visual Studio instance to use.</p aram> 123 /// <param name="dte">Interface to an open Visual Studio instance to use.</p aram>
91 /// <param name="name">Name to give newly created solution.</param> 124 /// <param name="name">Name to give newly created solution.</param>
92 /// <param name="pepperCopyFrom">Platform name to copy existing settings fro m to pepper.</param> 125 /// <param name="pepperCopyFrom">Platform name to copy existing settings fro m to pepper.</param>
93 /// <param name="naclCopyFrom">Platform name to copy existing settings from to NaCl.</param> 126 /// <param name="naclCopyFrom">Platform name to copy existing settings from to NaCl.</param>
94 /// <param name="testContext">Test context used for finding deployment direc tory.</param> 127 /// <param name="testContext">Test context used for finding deployment direc tory.</param>
95 /// <returns>Path to the newly created solution.</returns> 128 /// <returns>Path to the newly created solution.</returns>
96 public static string CreateBlankValidNaClSolution( 129 public static string CreateBlankValidNaClSolution(
97 DTE2 dte, string name, string pepperCopyFrom, string naclCopyFrom, TestC ontext testContext) 130 DTE2 dte, string name, string pepperCopyFrom, string naclCopyFrom, TestC ontext testContext)
98 { 131 {
99 const string BlankSolution = "BlankValidSolution"; 132 string blankSolution = "BlankValidSolution";
133 string srcSolution = blankSolution;
134 if (IsVS2012())
135 srcSolution += "2012";
100 string newSolutionDir = Path.Combine(testContext.DeploymentDirectory, name ); 136 string newSolutionDir = Path.Combine(testContext.DeploymentDirectory, name );
101 string newSolution = Path.Combine(newSolutionDir, BlankSolution + ".sln"); 137 string newSolution = Path.Combine(newSolutionDir, blankSolution + ".sln");
102 CopyDirectory(Path.Combine(testContext.DeploymentDirectory, BlankSolution) , newSolutionDir); 138 CopyDirectory(Path.Combine(testContext.DeploymentDirectory, srcSolution), newSolutionDir);
103 139
104 try 140 try
105 { 141 {
106 dte.Solution.Open(newSolution); 142 dte.Solution.Open(newSolution);
107 Project proj = dte.Solution.Projects.Item(NaClProjectUniqueName); 143 Project proj = dte.Solution.Projects.Item(NaClProjectUniqueName);
108 144
109 // Order matters if copying from the other Native Client type. 145 // Order matters if copying from the other Native Client type.
110 if (PropertyManager.IsNaClPlatform(pepperCopyFrom)) 146 if (PropertyManager.IsNaClPlatform(pepperCopyFrom))
111 { 147 {
112 // create nacl platforms first 148 // create nacl platforms first
113 proj.ConfigurationManager.AddPlatform(Strings.NaCl64PlatformName, nacl CopyFrom, true); 149 AddPlatform(proj, Strings.NaCl64PlatformName, naclCopyFrom);
114 proj.ConfigurationManager.AddPlatform(Strings.NaCl32PlatformName, nacl CopyFrom, true); 150 AddPlatform(proj, Strings.NaCl32PlatformName, naclCopyFrom);
115 proj.ConfigurationManager.AddPlatform(Strings.NaClARMPlatformName, nac lCopyFrom, true); 151 AddPlatform(proj, Strings.NaClARMPlatformName, naclCopyFrom);
116 proj.ConfigurationManager.AddPlatform(Strings.PNaClPlatformName, naclC opyFrom, true); 152 AddPlatform(proj, Strings.PNaClPlatformName, naclCopyFrom);
117 proj.ConfigurationManager.AddPlatform(Strings.PepperPlatformName, pepp erCopyFrom, true); 153 AddPlatform(proj, Strings.PepperPlatformName, pepperCopyFrom);
118 } 154 }
119 else 155 else
120 { 156 {
121 // create pepper platform first 157 // create pepper platform first
122 proj.ConfigurationManager.AddPlatform(Strings.PepperPlatformName, pepp erCopyFrom, true); 158 AddPlatform(proj, Strings.PepperPlatformName, pepperCopyFrom);
123 proj.ConfigurationManager.AddPlatform(Strings.NaCl64PlatformName, nacl CopyFrom, true); 159 AddPlatform(proj, Strings.NaCl64PlatformName, naclCopyFrom);
124 proj.ConfigurationManager.AddPlatform(Strings.NaCl32PlatformName, nacl CopyFrom, true); 160 AddPlatform(proj, Strings.NaCl32PlatformName, naclCopyFrom);
125 proj.ConfigurationManager.AddPlatform(Strings.NaClARMPlatformName, nac lCopyFrom, true); 161 AddPlatform(proj, Strings.NaClARMPlatformName, naclCopyFrom);
126 proj.ConfigurationManager.AddPlatform(Strings.PNaClPlatformName, naclC opyFrom, true); 162 AddPlatform(proj, Strings.PNaClPlatformName, naclCopyFrom);
127 } 163 }
128 164
165 proj.Save();
166
129 // Set the active solution configuration to Debug|NaCl64. 167 // Set the active solution configuration to Debug|NaCl64.
130 SetSolutionConfiguration(dte, NaClProjectUniqueName, "Debug", Strings.Na Cl64PlatformName); 168 SetSolutionConfiguration(dte, NaClProjectUniqueName, "Debug", Strings.Na Cl64PlatformName);
131 169
132 proj.Save();
133 dte.Solution.SaveAs(newSolution); 170 dte.Solution.SaveAs(newSolution);
171
172 SetSolutionConfiguration(dte, NaClProjectUniqueName, "Release", Strings. NaCl64PlatformName);
173
174 dte.Solution.SaveAs(newSolution);
175
134 } 176 }
135 finally 177 finally
136 { 178 {
137 if (dte.Solution != null) 179 if (dte.Solution != null)
138 { 180 {
139 dte.Solution.Close(); 181 dte.Solution.Close();
140 } 182 }
141 } 183 }
142 184
143 return newSolution; 185 return newSolution;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 506 }
465 507
466 foreach (DirectoryInfo subdir in dir.GetDirectories()) 508 foreach (DirectoryInfo subdir in dir.GetDirectories())
467 { 509 {
468 string path = Path.Combine(dest, subdir.Name); 510 string path = Path.Combine(dest, subdir.Name);
469 CopyDirectory(subdir.FullName, path); 511 CopyDirectory(subdir.FullName, path);
470 } 512 }
471 } 513 }
472 } 514 }
473 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698