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

Side by Side Diff: ceee/ie/plugin/bho/events_funnel_unittest.cc

Issue 4989002: Firing event to broker without worker thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 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 EventsFunnel. 5 // Unit tests for EventsFunnel.
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "ceee/ie/common/ceee_module_util.h" 9 #include "ceee/ie/common/ceee_module_util.h"
10 #include "ceee/ie/plugin/bho/events_funnel.h" 10 #include "ceee/ie/plugin/bho/events_funnel.h"
11 #include "ceee/testing/utils/mock_static.h" 11 #include "ceee/testing/utils/mock_static.h"
12 #include "gmock/gmock.h" 12 #include "gmock/gmock.h"
13 #include "gtest/gtest.h" 13 #include "gtest/gtest.h"
14 14
15 namespace { 15 namespace {
16 16
17 using testing::StrEq; 17 using testing::StrEq;
18 18
19 MOCK_STATIC_CLASS_BEGIN(MockCeeeModuleUtils)
20 MOCK_STATIC_INIT_BEGIN(MockCeeeModuleUtils)
21 MOCK_STATIC_INIT2(ceee_module_util::FireEventToBroker,
Sigurður Ásgeirsson 2010/11/19 18:29:30 Excellent! :D
22 FireEventToBroker);
23 MOCK_STATIC_INIT_END()
24 MOCK_STATIC2(void, , FireEventToBroker, const std::string&,
25 const std::string&);
26 MOCK_STATIC_CLASS_END(MockCeeeModuleUtils)
27
28 // Test subclass used to provide access to protected functionality in the 19 // Test subclass used to provide access to protected functionality in the
29 // EventsFunnel class. 20 // EventsFunnel class.
30 class TestEventsFunnel : public EventsFunnel { 21 class TestEventsFunnel : public EventsFunnel {
31 public: 22 public:
32 TestEventsFunnel() : EventsFunnel(true) {}
33
34 HRESULT CallSendEvent(const char* event_name, const Value& event_args) { 23 HRESULT CallSendEvent(const char* event_name, const Value& event_args) {
35 return SendEvent(event_name, event_args); 24 return SendEvent(event_name, event_args);
36 } 25 }
26
27 MOCK_METHOD2(SendEventToBroker, HRESULT(const char*, const char*));
37 }; 28 };
38 29
39 TEST(EventsFunnelTest, SendEvent) { 30 TEST(EventsFunnelTest, SendEvent) {
40 TestEventsFunnel events_funnel; 31 TestEventsFunnel events_funnel;
41 MockCeeeModuleUtils mock_ceee_module;
42 32
43 static const char* kEventName = "MADness"; 33 static const char* kEventName = "MADness";
44 DictionaryValue event_args; 34 DictionaryValue event_args;
45 event_args.SetInteger("Answer to the Ultimate Question of Life," 35 event_args.SetInteger("Answer to the Ultimate Question of Life,"
46 "the Universe, and Everything", 42); 36 "the Universe, and Everything", 42);
47 event_args.SetString("AYBABTU", "All your base are belong to us"); 37 event_args.SetString("AYBABTU", "All your base are belong to us");
48 event_args.SetReal("www.unrealtournament.com", 3.0); 38 event_args.SetReal("www.unrealtournament.com", 3.0);
49 39
50 ListValue args_list; 40 ListValue args_list;
51 args_list.Append(event_args.DeepCopy()); 41 args_list.Append(event_args.DeepCopy());
52 42
53 std::string event_args_str; 43 std::string event_args_str;
54 base::JSONWriter::Write(&args_list, false, &event_args_str); 44 base::JSONWriter::Write(&args_list, false, &event_args_str);
55 45
56 EXPECT_CALL(mock_ceee_module, FireEventToBroker(StrEq(kEventName), 46 EXPECT_CALL(events_funnel, SendEventToBroker(StrEq(kEventName),
57 StrEq(event_args_str))).Times(1); 47 StrEq(event_args_str))).Times(1);
58 EXPECT_HRESULT_SUCCEEDED( 48 EXPECT_HRESULT_SUCCEEDED(
59 events_funnel.CallSendEvent(kEventName, event_args)); 49 events_funnel.CallSendEvent(kEventName, event_args));
60 } 50 }
61 51
62 } // namespace 52 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698