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

Side by Side Diff: chromeos/dbus/ibus/ibus_engine_service_unittest.cc

Issue 10830004: Fix wrong usage of MethodCall resposne. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Same for IBusEngineService Created 8 years, 5 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
« no previous file with comments | « chromeos/dbus/ibus/ibus_engine_service.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/dbus/ibus/ibus_engine_service.h" 5 #include "chromeos/dbus/ibus/ibus_engine_service.h"
6 6
7 #include <map> 7 #include <map>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }; 56 };
57 57
58 // Used for method call empty response evaluation. 58 // Used for method call empty response evaluation.
59 class EmptyResponseExpectation { 59 class EmptyResponseExpectation {
60 public: 60 public:
61 explicit EmptyResponseExpectation(const uint32 serial_no) 61 explicit EmptyResponseExpectation(const uint32 serial_no)
62 : serial_no_(serial_no) {} 62 : serial_no_(serial_no) {}
63 63
64 // Evaluates the given |resposne| has no argument. 64 // Evaluates the given |resposne| has no argument.
65 void Evaluate(dbus::Response* response) { 65 void Evaluate(dbus::Response* response) {
66 scoped_ptr<dbus::Response> response_deleter(response);
66 EXPECT_EQ(serial_no_, response->GetReplySerial()); 67 EXPECT_EQ(serial_no_, response->GetReplySerial());
67 dbus::MessageReader reader(response); 68 dbus::MessageReader reader(response);
68 EXPECT_FALSE(reader.HasMoreData()); 69 EXPECT_FALSE(reader.HasMoreData());
69 } 70 }
70 71
71 private: 72 private:
72 const uint32 serial_no_; 73 const uint32 serial_no_;
73 74
74 DISALLOW_COPY_AND_ASSIGN(EmptyResponseExpectation); 75 DISALLOW_COPY_AND_ASSIGN(EmptyResponseExpectation);
75 }; 76 };
76 77
77 // Used for method call a boolean response evaluation. 78 // Used for method call a boolean response evaluation.
78 class BoolResponseExpectation { 79 class BoolResponseExpectation {
79 public: 80 public:
80 explicit BoolResponseExpectation(uint32 serial_no, bool result) 81 explicit BoolResponseExpectation(uint32 serial_no, bool result)
81 : serial_no_(serial_no), 82 : serial_no_(serial_no),
82 result_(result) {} 83 result_(result) {}
83 84
84 // Evaluates the given |resposne| has only one boolean and which is equals to 85 // Evaluates the given |resposne| has only one boolean and which is equals to
85 // |result_| which is given in ctor. 86 // |result_| which is given in ctor.
86 void Evaluate(dbus::Response* response) { 87 void Evaluate(dbus::Response* response) {
88 scoped_ptr<dbus::Response> response_deleter(response);
87 EXPECT_EQ(serial_no_, response->GetReplySerial()); 89 EXPECT_EQ(serial_no_, response->GetReplySerial());
88 dbus::MessageReader reader(response); 90 dbus::MessageReader reader(response);
89 bool result = false; 91 bool result = false;
90 EXPECT_TRUE(reader.PopBool(&result)); 92 EXPECT_TRUE(reader.PopBool(&result));
91 EXPECT_EQ(result_, result); 93 EXPECT_EQ(result_, result);
92 EXPECT_FALSE(reader.HasMoreData()); 94 EXPECT_FALSE(reader.HasMoreData());
93 } 95 }
94 96
95 private: 97 private:
96 uint32 serial_no_; 98 uint32 serial_no_;
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) 900 EXPECT_CALL(*mock_exported_object_, SendSignal(_))
899 .WillOnce(Invoke(&expectation, 901 .WillOnce(Invoke(&expectation,
900 &RequireSurroundingTextExpectation::Evaluate)); 902 &RequireSurroundingTextExpectation::Evaluate));
901 903
902 // Emit signal. 904 // Emit signal.
903 service_->RequireSurroundingText(); 905 service_->RequireSurroundingText();
904 } 906 }
905 907
906 908
907 } // namespace chromeos 909 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/ibus/ibus_engine_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698