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

Side by Side Diff: chrome/browser/ui/cocoa/view_id_util_browsertest.mm

Issue 1152613003: Implement sidebar support for extension action popups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move SidebarManager to ExtensionSystem and remove notifications Created 5 years, 6 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
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/devtools/devtools_window_testing.h" 10 #include "chrome/browser/devtools/devtools_window_testing.h"
11 #include "chrome/browser/download/download_shelf.h" 11 #include "chrome/browser/download/download_shelf.h"
12 #include "chrome/browser/extensions/sidebar_manager.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/cocoa/view_id_util.h" 17 #include "chrome/browser/ui/cocoa/view_id_util.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/browser/ui/view_ids.h"
17 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
19 #include "components/bookmarks/browser/bookmark_model.h" 22 #include "components/bookmarks/browser/bookmark_model.h"
20 #include "components/bookmarks/browser/bookmark_utils.h" 23 #include "components/bookmarks/browser/bookmark_utils.h"
21 #include "components/bookmarks/test/bookmark_test_helpers.h" 24 #include "components/bookmarks/test/bookmark_test_helpers.h"
22 #include "extensions/common/switches.h" 25 #include "extensions/common/switches.h"
23 26
24 using bookmarks::BookmarkModel; 27 using bookmarks::BookmarkModel;
25 using content::OpenURLParams; 28 using content::OpenURLParams;
26 using content::Referrer; 29 using content::Referrer;
27 30
31 const char kSimplePage[] = "files/sidebar/simple_page.html";
32
28 // Basic sanity check of ViewID use on the mac. 33 // Basic sanity check of ViewID use on the mac.
29 class ViewIDTest : public InProcessBrowserTest { 34 class ViewIDTest : public InProcessBrowserTest {
30 public: 35 public:
31 ViewIDTest() : root_window_(nil) { 36 ViewIDTest() : root_window_(nil) {
32 base::CommandLine::ForCurrentProcess()->AppendSwitch( 37 base::CommandLine::ForCurrentProcess()->AppendSwitch(
33 extensions::switches::kEnableExperimentalExtensionApis); 38 extensions::switches::kEnableExperimentalExtensionApis);
34 } 39 }
35 40
36 void CheckViewID(ViewID view_id, bool should_have) { 41 void CheckViewID(ViewID view_id, bool should_have) {
37 if (!root_window_) 42 if (!root_window_)
38 root_window_ = browser()->window()->GetNativeWindow(); 43 root_window_ = browser()->window()->GetNativeWindow();
39 44
40 ASSERT_TRUE(root_window_); 45 ASSERT_TRUE(root_window_);
41 NSView* view = view_id_util::GetView(root_window_, view_id); 46 NSView* view = view_id_util::GetView(root_window_, view_id);
42 EXPECT_EQ(should_have, !!view) << " Failed id=" << view_id; 47 EXPECT_EQ(should_have, !!view) << " Failed id=" << view_id;
43 } 48 }
44 49
45 void DoTest() { 50 void DoTest() {
46 // Make sure FindBar is created to test VIEW_ID_FIND_IN_PAGE_TEXT_FIELD. 51 // Make sure FindBar is created to test VIEW_ID_FIND_IN_PAGE_TEXT_FIELD.
47 chrome::ShowFindBar(browser()); 52 chrome::ShowFindBar(browser());
48 53
54 // Make sure sidebar is created to test VIEW_ID_SIDE_BAR_CONTAINER.
55 const char sidebar_content_id[] = "test_content_id";
56 GURL test_page_url = test_server()->GetURL(kSimplePage);
57 extensions::SidebarManager* sidebar_manager =
58 extensions::SidebarManager::GetFromContext(browser()->profile());
59
60 sidebar_manager->ShowSidebar(
61 static_cast<content::WebContents*>(
62 browser()->tab_strip_model()->GetActiveWebContents()),
63 sidebar_content_id, test_page_url, browser());
64
49 // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED 65 // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED
50 DevToolsWindow* devtools_window = 66 DevToolsWindow* devtools_window =
51 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true); 67 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true);
52 68
53 // Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF 69 // Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF
54 browser()->window()->GetDownloadShelf()->Show(); 70 browser()->window()->GetDownloadShelf()->Show();
55 71
56 // Create a bookmark to test VIEW_ID_BOOKMARK_BAR_ELEMENT 72 // Create a bookmark to test VIEW_ID_BOOKMARK_BAR_ELEMENT
57 BookmarkModel* bookmark_model = 73 BookmarkModel* bookmark_model =
58 BookmarkModelFactory::GetForProfile(browser()->profile()); 74 BookmarkModelFactory::GetForProfile(browser()->profile());
59 if (bookmark_model) { 75 if (bookmark_model) {
60 if (!bookmark_model->loaded()) 76 if (!bookmark_model->loaded())
61 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); 77 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
62 78
63 bookmarks::AddIfNotBookmarked(bookmark_model, 79 bookmarks::AddIfNotBookmarked(bookmark_model,
64 GURL(url::kAboutBlankURL), 80 GURL(url::kAboutBlankURL),
65 base::ASCIIToUTF16("about")); 81 base::ASCIIToUTF16("about"));
66 } 82 }
67 83
68 for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) { 84 for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) {
69 // Mac implementation does not support following ids yet. 85 // Mac implementation does not support following ids yet.
70 if (i == VIEW_ID_STAR_BUTTON || 86 if (i == VIEW_ID_STAR_BUTTON || i == VIEW_ID_BROWSER_ACTION ||
71 i == VIEW_ID_CONTENTS_SPLIT || 87 i == VIEW_ID_SIDE_BAR_SPLIT || i == VIEW_ID_SIDE_BAR_VIEW ||
72 i == VIEW_ID_BROWSER_ACTION || 88 i == VIEW_ID_FEEDBACK_BUTTON || i == VIEW_ID_SCRIPT_BUBBLE ||
73 i == VIEW_ID_FEEDBACK_BUTTON || 89 i == VIEW_ID_MIC_SEARCH_BUTTON || i == VIEW_ID_TRANSLATE_BUTTON) {
74 i == VIEW_ID_SCRIPT_BUBBLE ||
75 i == VIEW_ID_MIC_SEARCH_BUTTON ||
76 i == VIEW_ID_TRANSLATE_BUTTON) {
77 continue; 90 continue;
78 } 91 }
79 92
80 CheckViewID(static_cast<ViewID>(i), true); 93 CheckViewID(static_cast<ViewID>(i), true);
81 } 94 }
82 95
83 CheckViewID(VIEW_ID_TAB, true); 96 CheckViewID(VIEW_ID_TAB, true);
84 CheckViewID(VIEW_ID_TAB_STRIP, true); 97 CheckViewID(VIEW_ID_TAB_STRIP, true);
85 CheckViewID(VIEW_ID_PREDEFINED_COUNT, false); 98 CheckViewID(VIEW_ID_PREDEFINED_COUNT, false);
86 99
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 134 }
122 135
123 // Open the 11th tab. 136 // Open the 11th tab.
124 browser()->OpenURL(OpenURLParams(GURL(url::kAboutBlankURL), 137 browser()->OpenURL(OpenURLParams(GURL(url::kAboutBlankURL),
125 Referrer(), 138 Referrer(),
126 NEW_BACKGROUND_TAB, 139 NEW_BACKGROUND_TAB,
127 ui::PAGE_TRANSITION_TYPED, 140 ui::PAGE_TRANSITION_TYPED,
128 false)); 141 false));
129 CheckViewID(VIEW_ID_TAB_LAST, true); 142 CheckViewID(VIEW_ID_TAB_LAST, true);
130 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698