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

Side by Side Diff: ui/app_list/views/search_box_view_unittest.cc

Issue 2273263002: MacViewsBrowser: Fix omnibox crash due to failed DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile. Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_list/views/search_box_view.h" 5 #include "ui/app_list/views/search_box_view.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "ui/app_list/test/app_list_test_view_delegate.h" 12 #include "ui/app_list/test/app_list_test_view_delegate.h"
13 #include "ui/app_list/views/search_box_view_delegate.h" 13 #include "ui/app_list/views/search_box_view_delegate.h"
14 #include "ui/views/controls/textfield/textfield.h" 14 #include "ui/views/controls/textfield/textfield.h"
15 #include "ui/views/controls/textfield/textfield_test_api.h"
15 #include "ui/views/test/widget_test.h" 16 #include "ui/views/test/widget_test.h"
16 17
17 namespace app_list { 18 namespace app_list {
18 namespace test { 19 namespace test {
19 20
20 class KeyPressCounterView : public views::View { 21 class KeyPressCounterView : public views::View {
21 public: 22 public:
22 KeyPressCounterView() : count_(0) {} 23 KeyPressCounterView() : count_(0) {}
23 ~KeyPressCounterView() override {} 24 ~KeyPressCounterView() override {}
24 25
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void ResetAutoLaunchTimeout() { 80 void ResetAutoLaunchTimeout() {
80 view_delegate_.set_auto_launch_timeout(base::TimeDelta()); 81 view_delegate_.set_auto_launch_timeout(base::TimeDelta());
81 } 82 }
82 83
83 int GetContentsViewKeyPressCountAndReset() { 84 int GetContentsViewKeyPressCountAndReset() {
84 return counter_view_->GetCountAndReset(); 85 return counter_view_->GetCountAndReset();
85 } 86 }
86 87
87 void KeyPress(ui::KeyboardCode key_code) { 88 void KeyPress(ui::KeyboardCode key_code) {
88 ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE); 89 ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
89 view_->search_box()->OnKeyPressed(event); 90 views::TextfieldTestApi test_api_(view_->search_box());
91 test_api_.OnKeyPressed(event);
90 // Emulates the input method. 92 // Emulates the input method.
91 if (::isalnum(static_cast<int>(key_code))) { 93 if (::isalnum(static_cast<int>(key_code))) {
92 base::char16 character = ::tolower(static_cast<int>(key_code)); 94 base::char16 character = ::tolower(static_cast<int>(key_code));
93 view_->search_box()->InsertText(base::string16(1, character)); 95 view_->search_box()->InsertText(base::string16(1, character));
94 } 96 }
95 } 97 }
96 98
97 std::string GetLastQueryAndReset() { 99 std::string GetLastQueryAndReset() {
98 base::string16 query = last_query_; 100 base::string16 query = last_query_;
99 last_query_.clear(); 101 last_query_.clear();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ResetAutoLaunchTimeout(); 161 ResetAutoLaunchTimeout();
160 162
161 // Clearing search box also cancels. 163 // Clearing search box also cancels.
162 SetLongAutoLaunchTimeout(); 164 SetLongAutoLaunchTimeout();
163 view()->ClearSearch(); 165 view()->ClearSearch();
164 EXPECT_EQ(base::TimeDelta(), GetAutoLaunchTimeout()); 166 EXPECT_EQ(base::TimeDelta(), GetAutoLaunchTimeout());
165 } 167 }
166 168
167 } // namespace test 169 } // namespace test
168 } // namespace app_list 170 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698