| OLD | NEW |
| 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 "ui/app_list/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/app_list/app_list_item_model.h" | 16 #include "ui/app_list/app_list_item_model.h" |
| 16 #include "ui/app_list/app_list_model.h" | 17 #include "ui/app_list/app_list_model.h" |
| 17 #include "ui/app_list/pagination_model.h" | 18 #include "ui/app_list/pagination_model.h" |
| 18 #include "ui/app_list/test/app_list_test_model.h" | 19 #include "ui/app_list/test/app_list_test_model.h" |
| 19 #include "ui/app_list/views/app_list_item_view.h" | 20 #include "ui/app_list/views/app_list_item_view.h" |
| 20 #include "ui/app_list/views/test/apps_grid_view_test_api.h" | 21 #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
| 21 | 22 |
| 22 namespace app_list { | 23 namespace app_list { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 418 |
| 418 | 419 |
| 419 // After page switch, arrow keys select first item on current page. | 420 // After page switch, arrow keys select first item on current page. |
| 420 apps_grid_view_->SetSelectedView(GetItemViewAt(first_index)); | 421 apps_grid_view_->SetSelectedView(GetItemViewAt(first_index)); |
| 421 pagination_model_->SelectPage(1, false); | 422 pagination_model_->SelectPage(1, false); |
| 422 SimulateKeyPress(ui::VKEY_UP); | 423 SimulateKeyPress(ui::VKEY_UP); |
| 423 EXPECT_TRUE(apps_grid_view_->IsSelectedView(GetItemViewAt( | 424 EXPECT_TRUE(apps_grid_view_->IsSelectedView(GetItemViewAt( |
| 424 first_index_on_page2))); | 425 first_index_on_page2))); |
| 425 } | 426 } |
| 426 | 427 |
| 428 TEST_F(AppsGridViewTest, ItemLabelShortNameOverride) { |
| 429 // If the app's full name and short name differ, the title label's tooltip |
| 430 // should always be the full name of the app. |
| 431 std::string expected_text("xyz"); |
| 432 std::string expected_tooltip("tooltip"); |
| 433 model_->AddItem(expected_text, expected_tooltip); |
| 434 |
| 435 string16 actual_tooltip; |
| 436 AppListItemView* item_view = GetItemViewAt(0); |
| 437 ASSERT_TRUE(item_view); |
| 438 const views::Label* title_label = item_view->title(); |
| 439 EXPECT_TRUE(title_label->GetTooltipText( |
| 440 title_label->bounds().CenterPoint(), &actual_tooltip)); |
| 441 EXPECT_EQ(expected_tooltip, UTF16ToUTF8(actual_tooltip)); |
| 442 EXPECT_EQ(expected_text, UTF16ToUTF8(title_label->text())); |
| 443 } |
| 444 |
| 445 TEST_F(AppsGridViewTest, ItemLabelNoShortName) { |
| 446 // If the app's full name and short name are the same, use the default tooltip |
| 447 // behavior of the label (only show a tooltip if the title is truncated). |
| 448 std::string title("a"); |
| 449 model_->AddItem(title, title); |
| 450 |
| 451 string16 actual_tooltip; |
| 452 AppListItemView* item_view = GetItemViewAt(0); |
| 453 ASSERT_TRUE(item_view); |
| 454 const views::Label* title_label = item_view->title(); |
| 455 EXPECT_FALSE(title_label->GetTooltipText( |
| 456 title_label->bounds().CenterPoint(), &actual_tooltip)); |
| 457 EXPECT_EQ(title, UTF16ToUTF8(title_label->text())); |
| 458 } |
| 459 |
| 427 } // namespace test | 460 } // namespace test |
| 428 } // namespace app_list | 461 } // namespace app_list |
| OLD | NEW |