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

Side by Side Diff: experimental/visual_studio_plugin/src/NaClVsx.Package/NaClVsx.Package_UnitTestProject/ErrorBreakpointResolutionTest.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2010 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5 using System;
6 using System.Runtime.InteropServices;
7 using Google.MsAd7.BaseImpl;
8 using Microsoft.VisualStudio;
9 using Microsoft.VisualStudio.Debugger.Interop;
10 using Microsoft.VisualStudio.TestTools.UnitTesting;
11
12 namespace NaClVsx.Package_UnitTestProject {
13 /// <summary>
14 ///This is a test class for BreakpointErrorResolutionTest and is intended
15 ///to contain all BreakpointErrorResolutionTest Unit Tests
16 ///</summary>
17 [TestClass]
18 public class ErrorBreakpointResolutionTest {
19 /// <summary>
20 ///Gets or sets the test context which provides
21 ///information about and functionality for the current test run.
22 ///</summary>
23 public TestContext TestContext { get; set; }
24
25 #region Additional test attributes
26
27 //
28 //You can use the following additional attributes as you write your tests:
29 //
30 //Use ClassInitialize to run code before running the first test in the class
31 //[ClassInitialize()]
32 //public static void MyClassInitialize(TestContext testContext)
33 //{
34 //}
35 //
36 //Use ClassCleanup to run code after all tests in a class have run
37 //[ClassCleanup()]
38 //public static void MyClassCleanup()
39 //{
40 //}
41 //
42 //Use TestInitialize to run code before running each test
43 //[TestInitialize()]
44 //public void MyTestInitialize()
45 //{
46 //}
47 //
48 //Use TestCleanup to run code after each test has run
49 //[TestCleanup()]
50 //public void MyTestCleanup()
51 //{
52 //}
53 //
54
55 #endregion
56
57 /// <summary>
58 ///A test for SetType
59 ///</summary>
60 [TestMethod]
61 public void SetTypeTest() {
62 var target = new ErrorBreakpointResolution();
63 TestType(target, enum_BP_ERROR_TYPE.BPET_ALL);
64 TestType(target, enum_BP_ERROR_TYPE.BPET_GENERAL_ERROR);
65 TestType(target, enum_BP_ERROR_TYPE.BPET_GENERAL_WARNING);
66 TestType(target, enum_BP_ERROR_TYPE.BPET_NONE);
67 TestType(target, enum_BP_ERROR_TYPE.BPET_SEV_GENERAL);
68 TestType(target, enum_BP_ERROR_TYPE.BPET_SEV_HIGH);
69 TestType(target, enum_BP_ERROR_TYPE.BPET_SEV_LOW);
70 TestType(target, enum_BP_ERROR_TYPE.BPET_SEV_MASK);
71 TestType(target, enum_BP_ERROR_TYPE.BPET_TYPE_ERROR);
72 TestType(target, enum_BP_ERROR_TYPE.BPET_TYPE_MASK);
73 TestType(target, enum_BP_ERROR_TYPE.BPET_TYPE_WARNING);
74 }
75
76 /// <summary>
77 ///A test for SetMessage
78 ///</summary>
79 [TestMethod]
80 public void SetMessageTest() {
81 var target = new ErrorBreakpointResolution();
82 const string kMessage = "This is a test message";
83
84 var info = new BP_ERROR_RESOLUTION_INFO[1];
85 info[0] = new BP_ERROR_RESOLUTION_INFO();
86
87 target.Message = kMessage;
88 Assert.AreEqual(
89 target.GetResolutionInfo(enum_BPERESI_FIELDS.BPERESI_MESSAGE, info),
90 VSConstants.S_OK);
91 Assert.IsTrue(
92 (info[0].dwFields & enum_BPERESI_FIELDS.BPERESI_MESSAGE) != 0);
93 Assert.AreEqual(info[0].bstrMessage, kMessage);
94 }
95
96 /// <summary>
97 ///A test for SetLocation
98 ///</summary>
99 [TestMethod]
100 public void SetLocationTest() {
101 // We have to start by testing some assumptions about int pointers
102 IntPtr intPtr = IntPtr.Zero;
103 Assert.IsTrue(intPtr.Equals(IntPtr.Zero));
104 Assert.IsTrue(intPtr == IntPtr.Zero);
105
106 var target = new ErrorBreakpointResolution();
107 const enum_BP_TYPE kBpType = enum_BP_TYPE.BPT_CODE;
108 const ulong kAddress = 123456;
109 const string kTestPath = "C:\\test\\location";
110 var docContext = new DocumentContext(new DocumentPosition(kTestPath, 123)) ;
111 target.SetLocation(kBpType, kAddress, docContext);
112
113 var info = new BP_ERROR_RESOLUTION_INFO[1];
114 info[0] = new BP_ERROR_RESOLUTION_INFO();
115
116 // the usual tests for GetResolutionInfo
117 Assert.AreEqual(
118 target.GetResolutionInfo(
119 enum_BPERESI_FIELDS.BPERESI_BPRESLOCATION, info),
120 VSConstants.S_OK);
121 Assert.IsTrue(
122 (info[0].dwFields & enum_BPERESI_FIELDS.BPERESI_BPRESLOCATION) != 0);
123 Assert.AreEqual(
124 (enum_BP_TYPE) info[0].bpResLocation.bpType, enum_BP_TYPE.BPT_CODE);
125
126 // making sure we can extract the location info properly is harder
127 IntPtr pointer = info[0].bpResLocation.unionmember1;
128 var infoContext = Marshal.GetObjectForIUnknown(pointer) as CodeContext;
129 Assert.IsTrue(infoContext != null);
130 Assert.AreEqual(infoContext.Address, kAddress);
131 IDebugDocumentContext2 infoDocContext;
132 Assert.AreEqual(
133 infoContext.GetDocumentContext(out infoDocContext), VSConstants.S_OK);
134 Assert.AreEqual(infoDocContext, docContext);
135 Marshal.Release(pointer);
136 }
137
138 /// <summary>
139 ///A test for GetResolutionInfo
140 ///</summary>
141 [TestMethod]
142 public void GetResolutionInfoTest() {
143 var target = new ErrorBreakpointResolution();
144 const enum_BPERESI_FIELDS kDwFields = enum_BPERESI_FIELDS.BPERESI_TYPE |
145 enum_BPERESI_FIELDS.BPERESI_MESSAGE;
146 const string kWarningMessage = "A test warning has occurred";
147 const enum_BP_ERROR_TYPE kTestType =
148 enum_BP_ERROR_TYPE.BPET_GENERAL_WARNING;
149 target.Type = kTestType;
150 target.Message = kWarningMessage;
151
152 var info = new BP_ERROR_RESOLUTION_INFO[1];
153 Assert.AreEqual(
154 target.GetResolutionInfo(kDwFields, info), VSConstants.S_OK);
155 Assert.AreEqual(info[0].dwFields, kDwFields);
156 Assert.AreEqual(info[0].bstrMessage, kWarningMessage);
157 Assert.AreEqual(info[0].dwType, kTestType);
158 }
159
160 /// <summary>
161 ///A test for GetBreakpointType
162 ///</summary>
163 [TestMethod]
164 public void GetBreakpointTypeTest() {
165 var target = new ErrorBreakpointResolution();
166 // TODO: Initialize to an appropriate value
167 var pBpType = new enum_BP_TYPE[1];
168 // TODO: Initialize to an appropriate value
169 pBpType[0] = new enum_BP_TYPE();
170
171 Assert.AreEqual(target.GetBreakpointType(pBpType), VSConstants.S_OK);
172 Assert.AreEqual(pBpType[0], enum_BP_TYPE.BPT_CODE);
173 }
174
175 #region Private Implementation
176
177 private static void TestType(ErrorBreakpointResolution target,
178 enum_BP_ERROR_TYPE errorType) {
179 var info = new BP_ERROR_RESOLUTION_INFO[1];
180 info[0] = new BP_ERROR_RESOLUTION_INFO();
181
182 target.Type = errorType;
183 Assert.AreEqual(
184 target.GetResolutionInfo(enum_BPERESI_FIELDS.BPERESI_TYPE, info),
185 VSConstants.S_OK);
186 Assert.IsTrue((info[0].dwFields & enum_BPERESI_FIELDS.BPERESI_TYPE) != 0);
187 Assert.AreEqual(info[0].dwType, errorType);
188 }
189
190 #endregion
191 }
192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698