OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/views/extensions/chooser_dialog_view.h" | 5 #include "chrome/browser/ui/views/extensions/chooser_dialog_view.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chooser_controller/mock_chooser_controller.h" | 9 #include "chrome/browser/chooser_controller/mock_chooser_controller.h" |
10 #include "chrome/browser/ui/views/chooser_content_view.h" | 10 #include "chrome/browser/ui/views/chooser_content_view.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 EXPECT_TRUE(ok_button_->enabled()); | 165 EXPECT_TRUE(ok_button_->enabled()); |
166 EXPECT_TRUE(cancel_button_->enabled()); | 166 EXPECT_TRUE(cancel_button_->enabled()); |
167 | 167 |
168 // Remove option 1. | 168 // Remove option 1. |
169 mock_chooser_controller_->OptionRemoved(base::ASCIIToUTF16("b")); | 169 mock_chooser_controller_->OptionRemoved(base::ASCIIToUTF16("b")); |
170 // OK button is disabled since the selected option is removed. | 170 // OK button is disabled since the selected option is removed. |
171 EXPECT_FALSE(ok_button_->enabled()); | 171 EXPECT_FALSE(ok_button_->enabled()); |
172 EXPECT_TRUE(cancel_button_->enabled()); | 172 EXPECT_TRUE(cancel_button_->enabled()); |
173 } | 173 } |
174 | 174 |
175 TEST_F(ChooserDialogViewTest, SelectAnOptionAndUpdateTheSelectedOption) { | |
176 mock_chooser_controller_->OptionAdded(base::ASCIIToUTF16("a")); | |
177 mock_chooser_controller_->OptionAdded(base::ASCIIToUTF16("b")); | |
178 mock_chooser_controller_->OptionAdded(base::ASCIIToUTF16("c")); | |
179 EXPECT_FALSE(ok_button_->enabled()); | |
180 EXPECT_TRUE(cancel_button_->enabled()); | |
181 | |
182 // Select option 1. | |
183 table_view_->Select(1); | |
184 EXPECT_TRUE(ok_button_->enabled()); | |
185 EXPECT_TRUE(cancel_button_->enabled()); | |
186 | |
187 // Update option 1. | |
188 mock_chooser_controller_->OptionUpdated(base::ASCIIToUTF16("b"), | |
189 base::ASCIIToUTF16("d")); | |
190 EXPECT_TRUE(ok_button_->enabled()); | |
191 EXPECT_TRUE(cancel_button_->enabled()); | |
msw
2016/08/12 22:19:34
optional nit: remove "d" after this and check that
juncai
2016/08/15 18:11:19
Done.
| |
192 } | |
193 | |
175 TEST_F(ChooserDialogViewTest, | 194 TEST_F(ChooserDialogViewTest, |
176 AddAnOptionAndSelectItAndRemoveTheSelectedOption) { | 195 AddAnOptionAndSelectItAndRemoveTheSelectedOption) { |
177 mock_chooser_controller_->OptionAdded(base::ASCIIToUTF16("a")); | 196 mock_chooser_controller_->OptionAdded(base::ASCIIToUTF16("a")); |
178 EXPECT_FALSE(ok_button_->enabled()); | 197 EXPECT_FALSE(ok_button_->enabled()); |
179 EXPECT_TRUE(cancel_button_->enabled()); | 198 EXPECT_TRUE(cancel_button_->enabled()); |
180 | 199 |
181 // Select option 0. | 200 // Select option 0. |
182 table_view_->Select(0); | 201 table_view_->Select(0); |
183 EXPECT_TRUE(ok_button_->enabled()); | 202 EXPECT_TRUE(ok_button_->enabled()); |
184 EXPECT_TRUE(cancel_button_->enabled()); | 203 EXPECT_TRUE(cancel_button_->enabled()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 EXPECT_TRUE(cancel_button_->enabled()); | 288 EXPECT_TRUE(cancel_button_->enabled()); |
270 table_view_->Select(0); | 289 table_view_->Select(0); |
271 EXPECT_TRUE(ok_button_->enabled()); | 290 EXPECT_TRUE(ok_button_->enabled()); |
272 EXPECT_TRUE(cancel_button_->enabled()); | 291 EXPECT_TRUE(cancel_button_->enabled()); |
273 | 292 |
274 mock_chooser_controller_->OnDiscoveryStateChanged( | 293 mock_chooser_controller_->OnDiscoveryStateChanged( |
275 content::BluetoothChooser::DiscoveryState::IDLE); | 294 content::BluetoothChooser::DiscoveryState::IDLE); |
276 EXPECT_TRUE(ok_button_->enabled()); | 295 EXPECT_TRUE(ok_button_->enabled()); |
277 EXPECT_TRUE(cancel_button_->enabled()); | 296 EXPECT_TRUE(cancel_button_->enabled()); |
278 } | 297 } |
OLD | NEW |