OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Unit tests for WindowEventsFunnel. | 5 // Unit tests for WindowEventsFunnel. |
6 | 6 |
7 // MockWin32 can't be included after ChromeFrameHost because of an include | 7 // MockWin32 can't be included after ChromeFrameHost because of an include |
8 // incompatibility with atlwin.h. | 8 // incompatibility with atlwin.h. |
9 #include "ceee/testing/utils/mock_win32.h" // NOLINT | 9 #include "ceee/testing/utils/mock_win32.h" // NOLINT |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 event_args.SetReal("www.unrealtournament.com", 3.0); | 58 event_args.SetReal("www.unrealtournament.com", 3.0); |
59 | 59 |
60 ListValue args_list; | 60 ListValue args_list; |
61 args_list.Append(event_args.DeepCopy()); | 61 args_list.Append(event_args.DeepCopy()); |
62 | 62 |
63 std::string event_args_str; | 63 std::string event_args_str; |
64 base::JSONWriter::Write(&args_list, false, &event_args_str); | 64 base::JSONWriter::Write(&args_list, false, &event_args_str); |
65 | 65 |
66 class MockChromePostman : public ChromePostman { | 66 class MockChromePostman : public ChromePostman { |
67 public: | 67 public: |
68 MOCK_METHOD2(FireEvent, void(BSTR, BSTR)); | 68 MOCK_METHOD2(FireEvent, void(const char*, const char*)); |
69 }; | 69 }; |
70 // Simply instantiating the postman will register it as the | 70 // Simply instantiating the postman will register it as the |
71 // one and only singleton to use all the time. | 71 // one and only singleton to use all the time. |
72 CComObjectStackEx<testing::StrictMock<MockChromePostman>> postman; | 72 CComObjectStackEx<testing::StrictMock<MockChromePostman>> postman; |
73 EXPECT_CALL(postman, FireEvent( | 73 EXPECT_CALL(postman, FireEvent( |
74 StrEq(CComBSTR(kEventName).m_str), | 74 StrEq(kEventName), |
75 StrEq(CComBSTR(event_args_str.c_str()).m_str))).Times(1); | 75 StrEq(event_args_str.c_str()))).Times(1); |
76 EXPECT_HRESULT_SUCCEEDED(events_funnel.CallSendEvent(kEventName, event_args)); | 76 EXPECT_HRESULT_SUCCEEDED(events_funnel.CallSendEvent(kEventName, event_args)); |
77 } | 77 } |
78 | 78 |
79 // Mock IeIsInPrivateBrowsing. | 79 // Mock IeIsInPrivateBrowsing. |
80 MOCK_STATIC_CLASS_BEGIN(MockIeUtil) | 80 MOCK_STATIC_CLASS_BEGIN(MockIeUtil) |
81 MOCK_STATIC_INIT_BEGIN(MockIeUtil) | 81 MOCK_STATIC_INIT_BEGIN(MockIeUtil) |
82 MOCK_STATIC_INIT2(ie_util::GetIEIsInPrivateBrowsing, | 82 MOCK_STATIC_INIT2(ie_util::GetIEIsInPrivateBrowsing, |
83 GetIEIsInPrivateBrowsing); | 83 GetIEIsInPrivateBrowsing); |
84 MOCK_STATIC_INIT_END() | 84 MOCK_STATIC_INIT_END() |
85 MOCK_STATIC0(bool, , GetIEIsInPrivateBrowsing); | 85 MOCK_STATIC0(bool, , GetIEIsInPrivateBrowsing); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 int window_id = 42; | 147 int window_id = 42; |
148 | 148 |
149 scoped_ptr<Value> args(Value::CreateIntegerValue(window_id)); | 149 scoped_ptr<Value> args(Value::CreateIntegerValue(window_id)); |
150 EXPECT_CALL(window_events_funnel, SendEvent( | 150 EXPECT_CALL(window_events_funnel, SendEvent( |
151 StrEq(ext_event_names::kOnWindowRemoved), ValuesEqual(args.get()))). | 151 StrEq(ext_event_names::kOnWindowRemoved), ValuesEqual(args.get()))). |
152 WillOnce(Return(S_OK)); | 152 WillOnce(Return(S_OK)); |
153 EXPECT_HRESULT_SUCCEEDED(window_events_funnel.OnRemoved(window_id)); | 153 EXPECT_HRESULT_SUCCEEDED(window_events_funnel.OnRemoved(window_id)); |
154 } | 154 } |
155 | 155 |
156 } // namespace | 156 } // namespace |
OLD | NEW |