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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 598013003: Added views::ViewModelT<T>, a type-safe template version of ViewModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appsgridview-static-casts
Patch Set: Fix browser_test compile on ChromeOS (missing include). Created 6 years, 2 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 | « ash/shelf/shelf_view.h ('k') | chrome/browser/ui/views/tabs/stacked_tab_strip_layout.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_controller.h" 8 #include "ash/display/display_controller.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_button.h" 10 #include "ash/shelf/shelf_button.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
50 #include "content/public/test/browser_test_utils.h" 50 #include "content/public/test/browser_test_utils.h"
51 #include "extensions/browser/app_window/app_window.h" 51 #include "extensions/browser/app_window/app_window.h"
52 #include "extensions/browser/app_window/app_window_registry.h" 52 #include "extensions/browser/app_window/app_window_registry.h"
53 #include "extensions/browser/app_window/native_app_window.h" 53 #include "extensions/browser/app_window/native_app_window.h"
54 #include "extensions/browser/extension_system.h" 54 #include "extensions/browser/extension_system.h"
55 #include "extensions/common/constants.h" 55 #include "extensions/common/constants.h"
56 #include "extensions/common/switches.h" 56 #include "extensions/common/switches.h"
57 #include "extensions/test/extension_test_message_listener.h" 57 #include "extensions/test/extension_test_message_listener.h"
58 #include "testing/gtest/include/gtest/gtest.h" 58 #include "testing/gtest/include/gtest/gtest.h"
59 #include "ui/app_list/views/app_list_item_view.h"
59 #include "ui/app_list/views/apps_grid_view.h" 60 #include "ui/app_list/views/apps_grid_view.h"
60 #include "ui/aura/client/aura_constants.h" 61 #include "ui/aura/client/aura_constants.h"
61 #include "ui/aura/window.h" 62 #include "ui/aura/window.h"
62 #include "ui/events/event.h" 63 #include "ui/events/event.h"
63 #include "ui/events/test/event_generator.h" 64 #include "ui/events/test/event_generator.h"
64 65
65 using extensions::AppWindow; 66 using extensions::AppWindow;
66 using extensions::Extension; 67 using extensions::Extension;
67 using content::WebContents; 68 using content::WebContents;
68 69
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 generator.ClickLeftButton(); 1627 generator.ClickLeftButton();
1627 1628
1628 EXPECT_TRUE(service->IsAppListVisible()); 1629 EXPECT_TRUE(service->IsAppListVisible());
1629 app_list::AppsGridView* grid_view = 1630 app_list::AppsGridView* grid_view =
1630 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1631 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1631 GetRootGridView(); 1632 GetRootGridView();
1632 ASSERT_TRUE(grid_view); 1633 ASSERT_TRUE(grid_view);
1633 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1634 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1634 1635
1635 // There should be 2 items in our application list. 1636 // There should be 2 items in our application list.
1636 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); 1637 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1638 grid_view->view_model_for_test();
1637 EXPECT_EQ(2, vm_grid->view_size()); 1639 EXPECT_EQ(2, vm_grid->view_size());
1638 1640
1639 // Test #1: Drag an app list which does not exist yet item into the 1641 // Test #1: Drag an app list which does not exist yet item into the
1640 // launcher. Keeping it dragged, see that a new item gets created. Continuing 1642 // launcher. Keeping it dragged, see that a new item gets created. Continuing
1641 // to drag it out should remove it again. 1643 // to drag it out should remove it again.
1642 1644
1643 // Get over item #1 of the application list and press the mouse button. 1645 // Get over item #1 of the application list and press the mouse button.
1644 views::View* item1 = vm_grid->view_at(1); 1646 views::View* item1 = vm_grid->view_at(1);
1645 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); 1647 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen();
1646 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1648 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 generator.ClickLeftButton(); 1778 generator.ClickLeftButton();
1777 1779
1778 EXPECT_TRUE(service->IsAppListVisible()); 1780 EXPECT_TRUE(service->IsAppListVisible());
1779 app_list::AppsGridView* grid_view = 1781 app_list::AppsGridView* grid_view =
1780 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1782 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1781 GetRootGridView(); 1783 GetRootGridView();
1782 ASSERT_TRUE(grid_view); 1784 ASSERT_TRUE(grid_view);
1783 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1785 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1784 1786
1785 // There should be 2 items in our application list. 1787 // There should be 2 items in our application list.
1786 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); 1788 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1789 grid_view->view_model_for_test();
1787 EXPECT_EQ(2, vm_grid->view_size()); 1790 EXPECT_EQ(2, vm_grid->view_size());
1788 1791
1789 // Drag an app list item which does not exist yet in the shelf. 1792 // Drag an app list item which does not exist yet in the shelf.
1790 // Keeping it dragged, see that a new item gets created. 1793 // Keeping it dragged, see that a new item gets created.
1791 // Continuing to drag it out should remove it again. 1794 // Continuing to drag it out should remove it again.
1792 1795
1793 // Get over item #1 of the application list and press the mouse button. 1796 // Get over item #1 of the application list and press the mouse button.
1794 views::View* item1 = vm_grid->view_at(1); 1797 views::View* item1 = vm_grid->view_at(1);
1795 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); 1798 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen();
1796 bounds_grid_1.Offset(-origin.x(), -origin.y()); 1799 bounds_grid_1.Offset(-origin.x(), -origin.y());
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1953 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1951 app_list_bounds.CenterPoint().y()); 1954 app_list_bounds.CenterPoint().y());
1952 generator.ClickLeftButton(); 1955 generator.ClickLeftButton();
1953 base::MessageLoop::current()->RunUntilIdle(); 1956 base::MessageLoop::current()->RunUntilIdle();
1954 1957
1955 EXPECT_TRUE(service->IsAppListVisible()); 1958 EXPECT_TRUE(service->IsAppListVisible());
1956 app_list::AppsGridView* grid_view = 1959 app_list::AppsGridView* grid_view =
1957 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). 1960 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).
1958 GetRootGridView(); 1961 GetRootGridView();
1959 ASSERT_TRUE(grid_view); 1962 ASSERT_TRUE(grid_view);
1960 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); 1963 const views::ViewModelT<app_list::AppListItemView>* vm_grid =
1964 grid_view->view_model_for_test();
1961 EXPECT_EQ(2, vm_grid->view_size()); 1965 EXPECT_EQ(2, vm_grid->view_size());
1962 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); 1966 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen();
1963 // Test now that a click does create a new application tab. 1967 // Test now that a click does create a new application tab.
1964 TabStripModel* tab_strip = browser()->tab_strip_model(); 1968 TabStripModel* tab_strip = browser()->tab_strip_model();
1965 int tab_count = tab_strip->count(); 1969 int tab_count = tab_strip->count();
1966 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1970 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1967 bounds_grid_1.CenterPoint().y()); 1971 bounds_grid_1.CenterPoint().y());
1968 generator.ClickLeftButton(); 1972 generator.ClickLeftButton();
1969 base::MessageLoop::current()->RunUntilIdle(); 1973 base::MessageLoop::current()->RunUntilIdle();
1970 EXPECT_EQ(tab_count + 1, tab_strip->count()); 1974 EXPECT_EQ(tab_count + 1, tab_strip->count());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 chrome::GetSettingsUrl(std::string())); 2130 chrome::GetSettingsUrl(std::string()));
2127 Browser* settings_browser = 2131 Browser* settings_browser =
2128 settings_manager->FindBrowserForProfile(browser()->profile()); 2132 settings_manager->FindBrowserForProfile(browser()->profile());
2129 ASSERT_TRUE(settings_browser); 2133 ASSERT_TRUE(settings_browser);
2130 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); 2134 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false));
2131 EXPECT_EQ(item_count + 1, shelf_model->item_count()); 2135 EXPECT_EQ(item_count + 1, shelf_model->item_count());
2132 2136
2133 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. 2137 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded.
2134 // crbug.com/230464. 2138 // crbug.com/230464.
2135 } 2139 }
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698