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

Unified Diff: chrome/browser/cocoa/view_id_util_browsertest.cc

Issue 2973004: [Mac]Implement ViewID support. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Turns out that, it's not a good solution. Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/view_id_util.mm ('k') | chrome/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/view_id_util_browsertest.cc
diff --git a/chrome/browser/cocoa/view_id_util_browsertest.cc b/chrome/browser/cocoa/view_id_util_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4f6a00979fed953e3f66403ddf26684e063fb8c8
--- /dev/null
+++ b/chrome/browser/cocoa/view_id_util_browsertest.cc
@@ -0,0 +1,89 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/cocoa/view_id_util.h"
+#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+
+// Basic sanity check of ViewID use on the mac.
+class ViewIDTest : public InProcessBrowserTest {
+ public:
+ ViewIDTest() : root_window_(nil) {}
+
+ void CheckViewID(ViewID view_id, bool should_have) {
+ if (!root_window_)
+ root_window_ = browser()->window()->GetNativeHandle();
+
+ ASSERT_TRUE(root_window_);
+ NSView* view = view_id_util::GetView(root_window_, view_id);
+ EXPECT_EQ(should_have, !!view) << " Failed id=" << view_id;
+ }
+
+ private:
+ NSWindow* root_window_;
+};
+
+IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) {
+ // Make sure FindBar is created to test
+ // VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE.
+ browser()->ShowFindBar();
+
+ // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED
+ browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked,
+ true);
+ browser()->ToggleDevToolsWindow(false);
+
+ // Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF
+ browser()->window()->GetDownloadShelf()->Show();
+
+ // Create a bookmark to test VIEW_ID_BOOKMARK_BAR_ELEMENT
+ BookmarkModel* bookmark_model = browser()->profile()->GetBookmarkModel();
+ if (bookmark_model) {
+ if (!bookmark_model->IsLoaded())
+ ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model);
+
+ bookmark_model->SetURLStarred(GURL(chrome::kAboutBlankURL),
+ UTF8ToUTF16("about"), true);
+ }
+
+ for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) {
+ // Extension shelf is being removed, http://crbug.com/30178.
+ if (i == VIEW_ID_DEV_EXTENSION_SHELF)
+ continue;
+
+ // Mac implementation does not support following ids yet.
+ if (i == VIEW_ID_STAR_BUTTON ||
+ i == VIEW_ID_PAGE_MENU ||
+ i == VIEW_ID_AUTOCOMPLETE ||
+ i == VIEW_ID_CONTENTS_SPLIT ||
+ i == VIEW_ID_INFO_BAR_CONTAINER) {
+ continue;
+ }
+
+ CheckViewID(static_cast<ViewID>(i), true);
+ }
+
+ CheckViewID(VIEW_ID_TAB_STRIP, true);
+ CheckViewID(VIEW_ID_PREDEFINED_COUNT, false);
+}
+
+IN_PROC_BROWSER_TEST_F(ViewIDTest, Tab) {
+ CheckViewID(VIEW_ID_TAB_0, true);
+ CheckViewID(VIEW_ID_TAB_1, false);
+
+ browser()->OpenURL(GURL(chrome::kAboutBlankURL), GURL(),
+ NEW_BACKGROUND_TAB, PageTransition::TYPED);
+
+ CheckViewID(VIEW_ID_TAB_0, true);
+ CheckViewID(VIEW_ID_TAB_1, true);
+}
« no previous file with comments | « chrome/browser/cocoa/view_id_util.mm ('k') | chrome/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698