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

Side by Side Diff: ui/aura/mus/input_method_mus_unittest.cc

Issue 2728373003: Fixs bug resulting in double event delivery in mus (Closed)
Patch Set: global disable Created 3 years, 9 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 | « ui/aura/mus/input_method_mus.cc ('k') | ui/aura/test/mus/input_method_mus_test_api.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ui/aura/mus/input_method_mus.h" 5 #include "ui/aura/mus/input_method_mus.h"
6 6
7 #include "services/ui/public/interfaces/ime/ime.mojom.h" 7 #include "services/ui/public/interfaces/ime/ime.mojom.h"
8 #include "ui/aura/test/aura_test_base.h" 8 #include "ui/aura/test/aura_test_base.h"
9 #include "ui/aura/test/mus/input_method_mus_test_api.h"
9 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
10 #include "ui/base/ime/input_method_delegate.h" 11 #include "ui/base/ime/input_method_delegate.h"
11 12
12 namespace aura { 13 namespace aura {
13 namespace { 14 namespace {
14 15
15 // Empty implementation of InputMethodDelegate. 16 // Empty implementation of InputMethodDelegate.
16 class TestInputMethodDelegate : public ui::internal::InputMethodDelegate { 17 class TestInputMethodDelegate : public ui::internal::InputMethodDelegate {
17 public: 18 public:
18 TestInputMethodDelegate() {} 19 TestInputMethodDelegate() {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 private: 55 private:
55 ProcessKeyEventCallbacks process_key_event_callbacks_; 56 ProcessKeyEventCallbacks process_key_event_callbacks_;
56 57
57 DISALLOW_COPY_AND_ASSIGN(TestInputMethod); 58 DISALLOW_COPY_AND_ASSIGN(TestInputMethod);
58 }; 59 };
59 60
60 } // namespace 61 } // namespace
61 62
62 using InputMethodMusTest = test::AuraTestBaseMus; 63 using InputMethodMusTest = test::AuraTestBaseMus;
63 64
64 class InputMethodMusTestApi {
65 public:
66 static void SetInputMethod(InputMethodMus* input_method_mus,
67 ui::mojom::InputMethod* input_method) {
68 input_method_mus->input_method_ = input_method;
69 }
70 static void CallSendKeyEventToInputMethod(
71 InputMethodMus* input_method_mus,
72 const ui::KeyEvent& event,
73 std::unique_ptr<EventResultCallback> ack_callback) {
74 input_method_mus->SendKeyEventToInputMethod(event, std::move(ack_callback));
75 }
76
77 private:
78 DISALLOW_IMPLICIT_CONSTRUCTORS(InputMethodMusTestApi);
79 };
80
81 namespace { 65 namespace {
82 66
83 // Used in closure supplied to processing the event. 67 // Used in closure supplied to processing the event.
84 void RunFunctionWithEventResult(bool* was_run, ui::mojom::EventResult result) { 68 void RunFunctionWithEventResult(bool* was_run, ui::mojom::EventResult result) {
85 *was_run = true; 69 *was_run = true;
86 } 70 }
87 71
88 } // namespace 72 } // namespace
89 73
90 TEST_F(InputMethodMusTest, PendingCallbackRunFromDestruction) { 74 TEST_F(InputMethodMusTest, PendingCallbackRunFromDestruction) {
(...skipping 21 matching lines...) Expand all
112 EXPECT_EQ(2u, test_input_method.process_key_event_callbacks()->size()); 96 EXPECT_EQ(2u, test_input_method.process_key_event_callbacks()->size());
113 // Callback should not have been run yet. 97 // Callback should not have been run yet.
114 EXPECT_FALSE(was_event_result_callback_run); 98 EXPECT_FALSE(was_event_result_callback_run);
115 } 99 }
116 100
117 // When the destructor is run the callback should be run. 101 // When the destructor is run the callback should be run.
118 EXPECT_TRUE(was_event_result_callback_run); 102 EXPECT_TRUE(was_event_result_callback_run);
119 } 103 }
120 104
121 } // namespace aura 105 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/input_method_mus.cc ('k') | ui/aura/test/mus/input_method_mus_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698