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

Side by Side Diff: chrome_frame/test/com_message_event_unittest.cc

Issue 6825055: Include base/win/scoped_comptr.h instead of base/scoped_comptr_win.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert bad indentation, rebase Created 9 years, 8 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
« no previous file with comments | « chrome_frame/test/chrome_frame_ui_test_utils.cc ('k') | chrome_frame/test/ie_event_sink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome_frame/com_message_event.h" 5 #include "chrome_frame/com_message_event.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
(...skipping 13 matching lines...) Expand all
25 COM_INTERFACE_ENTRY(IOleContainer) 25 COM_INTERFACE_ENTRY(IOleContainer)
26 END_COM_MAP() 26 END_COM_MAP()
27 27
28 STDMETHOD(ParseDisplayName)(IBindCtx*, LPOLESTR, ULONG*, IMoniker**) { 28 STDMETHOD(ParseDisplayName)(IBindCtx*, LPOLESTR, ULONG*, IMoniker**) {
29 NOTREACHED(); 29 NOTREACHED();
30 return E_NOTIMPL; 30 return E_NOTIMPL;
31 } 31 }
32 STDMETHOD(EnumObjects)(DWORD, IEnumUnknown**) { 32 STDMETHOD(EnumObjects)(DWORD, IEnumUnknown**) {
33 NOTREACHED(); 33 NOTREACHED();
34 return E_NOTIMPL; 34 return E_NOTIMPL;
35 } 35 }
36 STDMETHOD(LockContainer)(BOOL) { 36 STDMETHOD(LockContainer)(BOOL) {
37 NOTREACHED(); 37 NOTREACHED();
38 return E_NOTIMPL; 38 return E_NOTIMPL;
39 } 39 }
40 }; 40 };
41 41
42 TEST(ComMessageEvent, WithDumbContainer) { 42 TEST(ComMessageEvent, WithDumbContainer) {
43 CComObject<MockDumbContainer>* container_obj = NULL; 43 CComObject<MockDumbContainer>* container_obj = NULL;
44 CComObject<MockDumbContainer>::CreateInstance(&container_obj); 44 CComObject<MockDumbContainer>::CreateInstance(&container_obj);
45 ScopedComPtr<IOleContainer> container(container_obj); 45 base::win::ScopedComPtr<IOleContainer> container(container_obj);
46 EXPECT_FALSE(!container); 46 EXPECT_FALSE(!container);
47 47
48 CComObject<FriendlyComMessageEvent>* event_obj = NULL; 48 CComObject<FriendlyComMessageEvent>* event_obj = NULL;
49 CComObject<FriendlyComMessageEvent>::CreateInstance(&event_obj); 49 CComObject<FriendlyComMessageEvent>::CreateInstance(&event_obj);
50 ScopedComPtr<IUnknown> event_ref(event_obj); 50 base::win::ScopedComPtr<IUnknown> event_ref(event_obj);
51 51
52 bool result = event_obj->Initialize(container, "hi", "http://www.foo.com/", 52 bool result = event_obj->Initialize(container, "hi", "http://www.foo.com/",
53 "message"); 53 "message");
54 EXPECT_TRUE(result); 54 EXPECT_TRUE(result);
55 EXPECT_TRUE(!event_obj->basic_event()); 55 EXPECT_TRUE(!event_obj->basic_event());
56 } 56 }
57 57
58 // Mock object to mimic a "smart" container, e.g. IE, that will 58 // Mock object to mimic a "smart" container, e.g. IE, that will
59 // be able to return an IHTMLDocument2 and 4, and from which you 59 // be able to return an IHTMLDocument2 and 4, and from which you
60 // can get an IHTMLEventObj implementation. Doubles as a mock 60 // can get an IHTMLEventObj implementation. Doubles as a mock
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 STDMETHODNOTIMP(get_offsetY, (long*)); 272 STDMETHODNOTIMP(get_offsetY, (long*));
273 STDMETHODNOTIMP(get_screenX, (long*)); 273 STDMETHODNOTIMP(get_screenX, (long*));
274 STDMETHODNOTIMP(get_screenY, (long*)); 274 STDMETHODNOTIMP(get_screenY, (long*));
275 STDMETHODNOTIMP(get_srcFilter, (IDispatch**)); 275 STDMETHODNOTIMP(get_srcFilter, (IDispatch**));
276 #undef STDMETHODNOTIMP 276 #undef STDMETHODNOTIMP
277 }; 277 };
278 278
279 TEST(ComMessageEvent, WithSmartContainer) { 279 TEST(ComMessageEvent, WithSmartContainer) {
280 CComObject<MockSmartContainer>* container_obj = NULL; 280 CComObject<MockSmartContainer>* container_obj = NULL;
281 CComObject<MockSmartContainer>::CreateInstance(&container_obj); 281 CComObject<MockSmartContainer>::CreateInstance(&container_obj);
282 ScopedComPtr<IOleContainer> container(container_obj); 282 base::win::ScopedComPtr<IOleContainer> container(container_obj);
283 EXPECT_FALSE(!container); 283 EXPECT_FALSE(!container);
284 284
285 CComObject<FriendlyComMessageEvent>* event_obj = NULL; 285 CComObject<FriendlyComMessageEvent>* event_obj = NULL;
286 CComObject<FriendlyComMessageEvent>::CreateInstance(&event_obj); 286 CComObject<FriendlyComMessageEvent>::CreateInstance(&event_obj);
287 ScopedComPtr<IUnknown> event_ref(event_obj); 287 base::win::ScopedComPtr<IUnknown> event_ref(event_obj);
288 288
289 bool succeeded = event_obj->Initialize(container, "hi", 289 bool succeeded = event_obj->Initialize(container, "hi",
290 "http://www.foo.com/", "message"); 290 "http://www.foo.com/", "message");
291 EXPECT_TRUE(succeeded); 291 EXPECT_TRUE(succeeded);
292 EXPECT_FALSE(!event_obj->basic_event()); 292 EXPECT_FALSE(!event_obj->basic_event());
293 293
294 // Name handled natively by CF's ComMessageEvent. 294 // Name handled natively by CF's ComMessageEvent.
295 DISPID dispid = -1; 295 DISPID dispid = -1;
296 LPOLESTR name = L"data"; 296 LPOLESTR name = L"data";
297 HRESULT hr = event_obj->GetIDsOfNames(IID_IDispatch, &name, 1, 297 HRESULT hr = event_obj->GetIDsOfNames(IID_IDispatch, &name, 1,
298 LOCALE_USER_DEFAULT, &dispid); 298 LOCALE_USER_DEFAULT, &dispid);
299 EXPECT_HRESULT_SUCCEEDED(hr); 299 EXPECT_HRESULT_SUCCEEDED(hr);
(...skipping 16 matching lines...) Expand all
316 EXPECT_EQ(result.vt, VT_BSTR); 316 EXPECT_EQ(result.vt, VT_BSTR);
317 EXPECT_EQ(wcscmp(result.bstrVal, L"hi"), 0); 317 EXPECT_EQ(wcscmp(result.bstrVal, L"hi"), 0);
318 318
319 // And now check passthrough. 319 // And now check passthrough.
320 result.Clear(); 320 result.Clear();
321 hr = dispatcher.GetProperty(MockSmartContainer::kDispId, &result); 321 hr = dispatcher.GetProperty(MockSmartContainer::kDispId, &result);
322 EXPECT_HRESULT_SUCCEEDED(hr); 322 EXPECT_HRESULT_SUCCEEDED(hr);
323 EXPECT_EQ(result.vt, VT_I4); 323 EXPECT_EQ(result.vt, VT_I4);
324 EXPECT_EQ(result.lVal, MockSmartContainer::kResultValue); 324 EXPECT_EQ(result.lVal, MockSmartContainer::kResultValue);
325 } 325 }
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_ui_test_utils.cc ('k') | chrome_frame/test/ie_event_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698