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

Unified Diff: chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm

Issue 22694002: InstantExtended: Nuke InstantOverlayController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 4 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
Index: chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm b/chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm
deleted file mode 100644
index 075b98125eaa1661084907153dda90f59952b784..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2012 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.
-
-#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
-
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.h"
-#include "chrome/browser/ui/search/instant_overlay_model.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
-#import "testing/gtest_mac.h"
-
-class OverlayableContentsControllerTest : public InProcessBrowserTest,
- public content::NotificationObserver {
- public:
- OverlayableContentsControllerTest() : instant_overlay_model_(NULL),
- visibility_changed_count_(0) {
- }
-
- virtual void SetUpOnMainThread() OVERRIDE {
- web_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(browser()->profile())));
- instant_overlay_model_.SetOverlayContents(web_contents_.get());
-
- controller_.reset([[OverlayableContentsController alloc]
- initWithBrowser:browser()]);
- [[controller_ view] setFrame:NSMakeRect(0, 0, 100, 200)];
- instant_overlay_model_.AddObserver([controller_ instantOverlayController]);
- }
-
- virtual void CleanUpOnMainThread() OVERRIDE {
- instant_overlay_model_.RemoveObserver(
- [controller_ instantOverlayController]);
- instant_overlay_model_.SetOverlayContents(NULL);
- controller_.reset();
- web_contents_.reset();
- }
-
- void VerifyOverlayFrame(CGFloat expected_height,
- InstantSizeUnits units) {
- NSRect container_bounds = [[controller_ view] bounds];
- NSRect overlay_frame =
- [web_contents_->GetView()->GetNativeView() frame];
-
- EXPECT_EQ(NSMinX(container_bounds), NSMinX(overlay_frame));
- EXPECT_EQ(NSWidth(container_bounds), NSWidth(overlay_frame));
- switch (units) {
- case INSTANT_SIZE_PIXELS:
- EXPECT_EQ(expected_height, NSHeight(overlay_frame));
- EXPECT_EQ(NSMaxY(container_bounds), NSMaxY(overlay_frame));
- break;
- case INSTANT_SIZE_PERCENT:
- EXPECT_EQ((expected_height * NSHeight(container_bounds)) / 100,
- NSHeight(overlay_frame));
- EXPECT_EQ(NSMaxY(container_bounds), NSMaxY(overlay_frame));
- }
- }
-
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE {
- if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED)
- ++visibility_changed_count_;
- }
-
- protected:
- InstantOverlayModel instant_overlay_model_;
- scoped_ptr<content::WebContents> web_contents_;
- base::scoped_nsobject<OverlayableContentsController> controller_;
- content::NotificationRegistrar registrar_;
- int visibility_changed_count_;
-};
-
-// Verify that the view is correctly laid out when size is specified in percent.
-IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, SizePerecent) {
- SearchMode mode;
- mode.mode = SearchMode::MODE_NTP;
- CGFloat expected_height = 30;
- InstantSizeUnits units = INSTANT_SIZE_PERCENT;
- instant_overlay_model_.SetOverlayState(mode, expected_height, units);
-
- EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview],
- [controller_ view]);
- VerifyOverlayFrame(expected_height, units);
-
- // Resize the view and verify that the overlay is also resized.
- [[controller_ view] setFrameSize:NSMakeSize(300, 400)];
- VerifyOverlayFrame(expected_height, units);
-}
-
-// Verify that the view is correctly laid out when size is specified in pixels.
-IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, SizePixels) {
- SearchMode mode;
- mode.mode = SearchMode::MODE_NTP;
- CGFloat expected_height = 30;
- InstantSizeUnits units = INSTANT_SIZE_PIXELS;
- instant_overlay_model_.SetOverlayState(mode, expected_height, units);
-
- EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview],
- [controller_ view]);
- VerifyOverlayFrame(expected_height, units);
-
- // Resize the view and verify that the overlay is also resized.
- [[controller_ view] setFrameSize:NSMakeSize(300, 400)];
- VerifyOverlayFrame(expected_height, units);
-}
-
-// Verify that the web contents is not hidden when just the height changes.
-IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HeightChangeNoHide) {
- SearchMode mode;
- mode.mode = SearchMode::MODE_SEARCH_SUGGESTIONS;
- instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT);
-
- registrar_.Add(this,
- content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
- content::Source<content::WebContents>(web_contents_.get()));
- EXPECT_EQ(0, visibility_changed_count_);
- instant_overlay_model_.SetOverlayState(mode, 11, INSTANT_SIZE_PERCENT);
- EXPECT_EQ(1, visibility_changed_count_);
-}

Powered by Google App Engine
This is Rietveld 408576698