| 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/chooser_content_view.h" | 5 #include "chrome/browser/ui/views/chooser_content_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/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "components/chooser_controller/mock_chooser_controller.h" | 10 #include "components/chooser_controller/mock_chooser_controller.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DISALLOW_COPY_AND_ASSIGN(ChooserContentViewTest); | 68 DISALLOW_COPY_AND_ASSIGN(ChooserContentViewTest); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 TEST_F(ChooserContentViewTest, InitialState) { | 71 TEST_F(ChooserContentViewTest, InitialState) { |
| 72 EXPECT_CALL(*mock_table_view_observer_, OnSelectionChanged()).Times(0); | 72 EXPECT_CALL(*mock_table_view_observer_, OnSelectionChanged()).Times(0); |
| 73 | 73 |
| 74 // Since "No devices found." needs to be displayed on the |table_view_|, | 74 // Since "No devices found." needs to be displayed on the |table_view_|, |
| 75 // the number of rows is 1. | 75 // the number of rows is 1. |
| 76 EXPECT_EQ(1, table_view_->RowCount()); | 76 EXPECT_EQ(1, table_view_->RowCount()); |
| 77 EXPECT_EQ( | 77 EXPECT_EQ( |
| 78 l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT), | 78 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT), |
| 79 table_model_->GetText(0, 0)); | 79 table_model_->GetText(0, 0)); |
| 80 // |table_view_| should be disabled since there is no option shown. | 80 // |table_view_| should be disabled since there is no option shown. |
| 81 EXPECT_FALSE(table_view_->enabled()); | 81 EXPECT_FALSE(table_view_->enabled()); |
| 82 // No option selected. | 82 // No option selected. |
| 83 EXPECT_EQ(0, table_view_->SelectedRowCount()); | 83 EXPECT_EQ(0, table_view_->SelectedRowCount()); |
| 84 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); | 84 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 TEST_F(ChooserContentViewTest, AddOption) { | 87 TEST_F(ChooserContentViewTest, AddOption) { |
| 88 EXPECT_CALL(*mock_table_view_observer_, OnSelectionChanged()).Times(0); | 88 EXPECT_CALL(*mock_table_view_observer_, OnSelectionChanged()).Times(0); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 EXPECT_EQ(base::ASCIIToUTF16("a"), table_model_->GetText(0, 0)); | 141 EXPECT_EQ(base::ASCIIToUTF16("a"), table_model_->GetText(0, 0)); |
| 142 EXPECT_TRUE(table_view_->enabled()); | 142 EXPECT_TRUE(table_view_->enabled()); |
| 143 EXPECT_EQ(0, table_view_->SelectedRowCount()); | 143 EXPECT_EQ(0, table_view_->SelectedRowCount()); |
| 144 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); | 144 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); |
| 145 | 145 |
| 146 mock_chooser_controller_->OptionRemoved(base::ASCIIToUTF16("a")); | 146 mock_chooser_controller_->OptionRemoved(base::ASCIIToUTF16("a")); |
| 147 // There is no option shown now. But since "No devices found." | 147 // There is no option shown now. But since "No devices found." |
| 148 // needs to be displayed on the |table_view_|, the number of rows is 1. | 148 // needs to be displayed on the |table_view_|, the number of rows is 1. |
| 149 EXPECT_EQ(1, table_view_->RowCount()); | 149 EXPECT_EQ(1, table_view_->RowCount()); |
| 150 EXPECT_EQ( | 150 EXPECT_EQ( |
| 151 l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT), | 151 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT), |
| 152 table_model_->GetText(0, 0)); | 152 table_model_->GetText(0, 0)); |
| 153 // |table_view_| should be disabled since all options are removed. | 153 // |table_view_| should be disabled since all options are removed. |
| 154 EXPECT_FALSE(table_view_->enabled()); | 154 EXPECT_FALSE(table_view_->enabled()); |
| 155 EXPECT_EQ(0, table_view_->SelectedRowCount()); | 155 EXPECT_EQ(0, table_view_->SelectedRowCount()); |
| 156 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); | 156 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 TEST_F(ChooserContentViewTest, AddAndRemoveOption) { | 159 TEST_F(ChooserContentViewTest, AddAndRemoveOption) { |
| 160 // Called from TableView::OnItemsRemoved(). | 160 // Called from TableView::OnItemsRemoved(). |
| 161 EXPECT_CALL(*mock_table_view_observer_, OnSelectionChanged()).Times(3); | 161 EXPECT_CALL(*mock_table_view_observer_, OnSelectionChanged()).Times(3); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 table_view_->Select(0); | 286 table_view_->Select(0); |
| 287 EXPECT_EQ(1, table_view_->SelectedRowCount()); | 287 EXPECT_EQ(1, table_view_->SelectedRowCount()); |
| 288 EXPECT_EQ(0, table_view_->FirstSelectedRow()); | 288 EXPECT_EQ(0, table_view_->FirstSelectedRow()); |
| 289 | 289 |
| 290 // Remove option 0. | 290 // Remove option 0. |
| 291 mock_chooser_controller_->OptionRemoved(base::ASCIIToUTF16("a")); | 291 mock_chooser_controller_->OptionRemoved(base::ASCIIToUTF16("a")); |
| 292 // There is no option shown now. But since "No devices found." | 292 // There is no option shown now. But since "No devices found." |
| 293 // needs to be displayed on the |table_view_|, the number of rows is 1. | 293 // needs to be displayed on the |table_view_|, the number of rows is 1. |
| 294 EXPECT_EQ(1, table_view_->RowCount()); | 294 EXPECT_EQ(1, table_view_->RowCount()); |
| 295 EXPECT_EQ( | 295 EXPECT_EQ( |
| 296 l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT), | 296 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT), |
| 297 table_model_->GetText(0, 0)); | 297 table_model_->GetText(0, 0)); |
| 298 // |table_view_| should be disabled since all options are removed. | 298 // |table_view_| should be disabled since all options are removed. |
| 299 EXPECT_FALSE(table_view_->enabled()); | 299 EXPECT_FALSE(table_view_->enabled()); |
| 300 // No option selected. | 300 // No option selected. |
| 301 EXPECT_EQ(0, table_view_->SelectedRowCount()); | 301 EXPECT_EQ(0, table_view_->SelectedRowCount()); |
| 302 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); | 302 EXPECT_EQ(-1, table_view_->FirstSelectedRow()); |
| 303 } | 303 } |
| 304 | 304 |
| 305 TEST_F(ChooserContentViewTest, ClickStyledLabelLink) { | 305 TEST_F(ChooserContentViewTest, ClickStyledLabelLink) { |
| 306 EXPECT_CALL(*mock_styled_label_listener_, | 306 EXPECT_CALL(*mock_styled_label_listener_, |
| 307 StyledLabelLinkClicked(styled_label_.get(), testing::_, 0)) | 307 StyledLabelLinkClicked(styled_label_.get(), testing::_, 0)) |
| 308 .Times(1); | 308 .Times(1); |
| 309 styled_label_->LinkClicked(nullptr, 0); | 309 styled_label_->LinkClicked(nullptr, 0); |
| 310 } | 310 } |
| OLD | NEW |