- Timestamp:
- Oct 2, 2020 12:28:00 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/tests/TestObserverService.cpp
r1 r86420 49 49 static nsIObserverService *anObserverService = NULL; 50 50 51 #ifdef VBOX 52 static bool testResult( nsresult rv ) { 53 if ( NS_SUCCEEDED( rv ) ) { 54 printf("...ok\n"); 55 return true; 56 } 57 printf("...failed, rv=0x%x\n", (int)rv); 58 return false; 59 } 60 #else 51 61 static void testResult( nsresult rv ) { 52 62 if ( NS_SUCCEEDED( rv ) ) { … … 57 67 return; 58 68 } 69 #endif 59 70 60 71 void printString(nsString &str) { 72 #ifdef VBOX /* asan complains about mixing different allocators */ 73 char *cstr = ToNewCString(str); 74 printf("%s", cstr); 75 nsMemory::Free(cstr); 76 #else 61 77 const char *cstr = ToNewCString(str); 62 78 printf("%s", cstr); 63 79 delete [] (char*)cstr; 80 #endif 64 81 } 65 82 … … 111 128 NS_GET_IID(nsIObserverService), 112 129 (void **) &anObserverService); 130 #ifdef VBOX 131 bool fSuccess = res == NS_OK; 132 #endif 113 133 114 134 if (res == NS_OK) { … … 121 141 printf("Adding Observer-A as observer of topic-A...\n"); 122 142 rv = anObserverService->AddObserver(aObserver, topicA.get(), PR_FALSE); 143 #ifdef VBOX 144 fSuccess = fSuccess && 145 #endif 123 146 testResult(rv); 124 147 125 148 printf("Adding Observer-B as observer of topic-A...\n"); 126 149 rv = anObserverService->AddObserver(bObserver, topicA.get(), PR_FALSE); 150 #ifdef VBOX 151 fSuccess = fSuccess && 152 #endif 127 153 testResult(rv); 128 154 129 155 printf("Adding Observer-B as observer of topic-B...\n"); 130 156 rv = anObserverService->AddObserver(bObserver, topicB.get(), PR_FALSE); 157 #ifdef VBOX 158 fSuccess = fSuccess && 159 #endif 131 160 testResult(rv); 132 161 … … 135 164 topicA.get(), 136 165 NS_LITERAL_STRING("Testing Notify(observer-A, topic-A)").get() ); 166 #ifdef VBOX 167 fSuccess = fSuccess && 168 #endif 137 169 testResult(rv); 138 170 … … 141 173 topicB.get(), 142 174 NS_LITERAL_STRING("Testing Notify(observer-B, topic-B)").get() ); 175 #ifdef VBOX 176 fSuccess = fSuccess && 177 #endif 143 178 testResult(rv); 144 179 … … 147 182 rv = anObserverService->EnumerateObservers(topicA.get(), getter_AddRefs(e)); 148 183 184 #ifdef VBOX 185 fSuccess = fSuccess && 186 #endif 149 187 testResult(rv); 150 188 … … 163 201 topicA.get(), 164 202 NS_LITERAL_STRING("during enumeration").get() ); 203 #ifdef VBOX 204 fSuccess = fSuccess && 205 #endif 165 206 testResult(rv); 166 207 } … … 170 211 printf("Removing Observer-A...\n"); 171 212 rv = anObserverService->RemoveObserver(aObserver, topicA.get()); 213 #ifdef VBOX 214 fSuccess = fSuccess && 215 #endif 172 216 testResult(rv); 173 217 … … 175 219 printf("Removing Observer-B (topic-A)...\n"); 176 220 rv = anObserverService->RemoveObserver(bObserver, topicB.get()); 221 #ifdef VBOX 222 fSuccess = fSuccess && 223 #endif 177 224 testResult(rv); 178 225 printf("Removing Observer-B (topic-B)...\n"); 179 226 rv = anObserverService->RemoveObserver(bObserver, topicA.get()); 180 testResult(rv); 181 182 } 227 #ifdef VBOX 228 fSuccess = fSuccess && 229 #endif 230 testResult(rv); 231 232 #ifdef VBOX 233 /* Cleanup: */ 234 nsrefcnt refs = bObserver->Release(); 235 fSuccess = fSuccess && refs == 0; 236 if (refs != 0) 237 printf("bObserver->Release() -> %d, expected 0\n", (int)refs); 238 239 refs = aObserver->Release(); 240 fSuccess = fSuccess && refs == 0; 241 if (refs != 0) 242 printf("aObserver->Release() -> %d, expected 0\n", (int)refs); 243 #endif 244 } 245 #ifdef VBOX 246 return fSuccess ? 0 : 1; 247 #else 183 248 return NS_OK; 184 } 249 #endif 250 }
Note:
See TracChangeset
for help on using the changeset viewer.