OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/bookmarks/bookmark_utils.h" | 9 #include "chrome/browser/bookmarks/bookmark_utils.h" |
10 #include "chrome/browser/download/download_shelf.h" | 10 #include "chrome/browser/download/download_shelf.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sidebar/sidebar_manager.h" | |
14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/cocoa/view_id_util.h" | 15 #include "chrome/browser/ui/cocoa/view_id_util.h" |
17 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
19 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
22 | 21 |
23 // Basic sanity check of ViewID use on the mac. | 22 // Basic sanity check of ViewID use on the mac. |
(...skipping 11 matching lines...) Expand all Loading... |
35 ASSERT_TRUE(root_window_); | 34 ASSERT_TRUE(root_window_); |
36 NSView* view = view_id_util::GetView(root_window_, view_id); | 35 NSView* view = view_id_util::GetView(root_window_, view_id); |
37 EXPECT_EQ(should_have, !!view) << " Failed id=" << view_id; | 36 EXPECT_EQ(should_have, !!view) << " Failed id=" << view_id; |
38 } | 37 } |
39 | 38 |
40 void DoTest() { | 39 void DoTest() { |
41 // Make sure FindBar is created to test | 40 // Make sure FindBar is created to test |
42 // VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE. | 41 // VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE. |
43 browser()->ShowFindBar(); | 42 browser()->ShowFindBar(); |
44 | 43 |
45 // Make sure sidebar is created to test VIEW_ID_SIDE_BAR_CONTAINER. | |
46 const char sidebar_content_id[] = "test_content_id"; | |
47 SidebarManager::GetInstance()->ShowSidebar( | |
48 browser()->GetSelectedTabContents(), sidebar_content_id); | |
49 SidebarManager::GetInstance()->ExpandSidebar( | |
50 browser()->GetSelectedTabContents(), sidebar_content_id); | |
51 | |
52 // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED | 44 // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED |
53 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked, | 45 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked, |
54 true); | 46 true); |
55 browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT); | 47 browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT); |
56 | 48 |
57 // Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF | 49 // Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF |
58 browser()->window()->GetDownloadShelf()->Show(); | 50 browser()->window()->GetDownloadShelf()->Show(); |
59 | 51 |
60 // Create a bookmark to test VIEW_ID_BOOKMARK_BAR_ELEMENT | 52 // Create a bookmark to test VIEW_ID_BOOKMARK_BAR_ELEMENT |
61 BookmarkModel* bookmark_model = browser()->profile()->GetBookmarkModel(); | 53 BookmarkModel* bookmark_model = browser()->profile()->GetBookmarkModel(); |
62 if (bookmark_model) { | 54 if (bookmark_model) { |
63 if (!bookmark_model->IsLoaded()) | 55 if (!bookmark_model->IsLoaded()) |
64 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model); | 56 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model); |
65 | 57 |
66 bookmark_utils::AddIfNotBookmarked( | 58 bookmark_utils::AddIfNotBookmarked( |
67 bookmark_model, GURL(chrome::kAboutBlankURL), ASCIIToUTF16("about")); | 59 bookmark_model, GURL(chrome::kAboutBlankURL), ASCIIToUTF16("about")); |
68 } | 60 } |
69 | 61 |
70 for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) { | 62 for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) { |
71 // Mac implementation does not support following ids yet. | 63 // Mac implementation does not support following ids yet. |
72 if (i == VIEW_ID_STAR_BUTTON || | 64 if (i == VIEW_ID_STAR_BUTTON || |
73 i == VIEW_ID_AUTOCOMPLETE || | 65 i == VIEW_ID_AUTOCOMPLETE || |
74 i == VIEW_ID_CONTENTS_SPLIT || | 66 i == VIEW_ID_CONTENTS_SPLIT || |
75 i == VIEW_ID_SIDE_BAR_SPLIT || | |
76 i == VIEW_ID_FEEDBACK_BUTTON || | 67 i == VIEW_ID_FEEDBACK_BUTTON || |
77 i == VIEW_ID_OMNIBOX) { | 68 i == VIEW_ID_OMNIBOX) { |
78 continue; | 69 continue; |
79 } | 70 } |
80 | 71 |
81 CheckViewID(static_cast<ViewID>(i), true); | 72 CheckViewID(static_cast<ViewID>(i), true); |
82 } | 73 } |
83 | 74 |
84 CheckViewID(VIEW_ID_TAB, true); | 75 CheckViewID(VIEW_ID_TAB, true); |
85 CheckViewID(VIEW_ID_TAB_STRIP, true); | 76 CheckViewID(VIEW_ID_TAB_STRIP, true); |
(...skipping 27 matching lines...) Expand all Loading... |
113 CheckViewID(static_cast<ViewID>(VIEW_ID_TAB_0 + i), true); | 104 CheckViewID(static_cast<ViewID>(VIEW_ID_TAB_0 + i), true); |
114 // VIEW_ID_TAB_LAST should always be available. | 105 // VIEW_ID_TAB_LAST should always be available. |
115 CheckViewID(VIEW_ID_TAB_LAST, true); | 106 CheckViewID(VIEW_ID_TAB_LAST, true); |
116 } | 107 } |
117 | 108 |
118 // Open the 11th tab. | 109 // Open the 11th tab. |
119 browser()->OpenURL(GURL(chrome::kAboutBlankURL), GURL(), | 110 browser()->OpenURL(GURL(chrome::kAboutBlankURL), GURL(), |
120 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_TYPED); | 111 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_TYPED); |
121 CheckViewID(VIEW_ID_TAB_LAST, true); | 112 CheckViewID(VIEW_ID_TAB_LAST, true); |
122 } | 113 } |
OLD | NEW |