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 |
index 4b3c0c369bb8734d3df7e440c2957ec6b7bb68ce..16ff3a2450b4374ff6d58482c986cdea5bd50500 100644 |
--- a/chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm |
+++ b/chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller_browsertest.mm |
@@ -5,6 +5,7 @@ |
#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
#include "chrome/browser/instant/instant_overlay_model.h" |
+#include "chrome/browser/instant/instant_service_factory.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_window.h" |
@@ -20,26 +21,26 @@ |
class OverlayableContentsControllerTest : public InProcessBrowserTest, |
public content::NotificationObserver { |
public: |
- OverlayableContentsControllerTest() : instant_overlay_model_(NULL), |
- visibility_changed_count_(0) { |
+ OverlayableContentsControllerTest() : 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() |
windowController:nil]); |
[[controller_ view] setFrame:NSMakeRect(0, 0, 100, 200)]; |
- instant_overlay_model_.AddObserver([controller_ instantOverlayController]); |
+ |
+ instant_overlay_model_.reset(new InstantOverlayModel( |
+ InstantServiceFactory::GetForProfile(browser()->profile()))); |
+ instant_overlay_model_->AddObserver([controller_ instantOverlayController]); |
} |
virtual void CleanUpOnMainThread() OVERRIDE { |
- instant_overlay_model_.RemoveObserver( |
+ instant_overlay_model_->RemoveObserver( |
[controller_ instantOverlayController]); |
- instant_overlay_model_.SetOverlayContents(NULL); |
controller_.reset(); |
web_contents_.reset(); |
} |
@@ -72,7 +73,7 @@ class OverlayableContentsControllerTest : public InProcessBrowserTest, |
} |
protected: |
- InstantOverlayModel instant_overlay_model_; |
+ scoped_ptr<InstantOverlayModel> instant_overlay_model_; |
scoped_ptr<content::WebContents> web_contents_; |
scoped_nsobject<OverlayableContentsController> controller_; |
content::NotificationRegistrar registrar_; |
@@ -81,11 +82,10 @@ class OverlayableContentsControllerTest : public InProcessBrowserTest, |
// Verify that the view is correctly laid out when size is specified in percent. |
IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, SizePerecent) { |
- chrome::search::Mode mode; |
- mode.mode = chrome::search::Mode::MODE_NTP; |
CGFloat expected_height = 30; |
InstantSizeUnits units = INSTANT_SIZE_PERCENT; |
- instant_overlay_model_.SetOverlayState(mode, expected_height, units); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ expected_height, units); |
EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview], |
[controller_ view]); |
@@ -98,41 +98,44 @@ IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, SizePerecent) { |
// Verify that the view is correctly laid out when size is specified in pixels. |
IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, SizePixels) { |
- chrome::search::Mode mode; |
- mode.mode = chrome::search::Mode::MODE_NTP; |
CGFloat expected_height = 30; |
InstantSizeUnits units = INSTANT_SIZE_PIXELS; |
- instant_overlay_model_.SetOverlayState(mode, expected_height, units); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ expected_height, units); |
EXPECT_NSEQ([web_contents_->GetView()->GetNativeView() superview], |
[controller_ view]); |
- VerifyOverlayFrame(expected_height, units); |
+ // TODO(sail): Remove the "- 1" when the overlay no longer has a separator. |
+ VerifyOverlayFrame(expected_height - 1, units); |
// Resize the view and verify that the overlay is also resized. |
[[controller_ view] setFrameSize:NSMakeSize(300, 400)]; |
- VerifyOverlayFrame(expected_height, units); |
+ // TODO(sail): Remove the "- 1" when the overlay no longer has a separator. |
+ VerifyOverlayFrame(expected_height - 1, units); |
} |
-// Verify that a shadow is not shown when the overlay covers the entire page |
-// or when the overlay is in NTP mode. |
+// Verify that a shadow is not shown when the overlay covers the entire page. |
+// or when the overlay is not showing. |
IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, NoShadowFullHeight) { |
- chrome::search::Mode mode; |
- mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS; |
- instant_overlay_model_.SetOverlayState(mode, 100, INSTANT_SIZE_PERCENT); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ 100, INSTANT_SIZE_PERCENT); |
EXPECT_FALSE([controller_ dropShadowView]); |
EXPECT_FALSE([controller_ drawDropShadow]); |
- mode.mode = chrome::search::Mode::MODE_NTP; |
- instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ 10, INSTANT_SIZE_PERCENT); |
+ EXPECT_TRUE([controller_ dropShadowView]); |
+ EXPECT_TRUE([controller_ drawDropShadow]); |
+ |
+ instant_overlay_model_->SetOverlayState(NULL, 0, INSTANT_SIZE_PIXELS); |
EXPECT_FALSE([controller_ dropShadowView]); |
EXPECT_FALSE([controller_ drawDropShadow]); |
} |
// Verify that a shadow is shown when the overlay is in search mode. |
IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, NoShadowNTP) { |
- chrome::search::Mode mode; |
- mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS; |
- instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ 10, INSTANT_SIZE_PERCENT); |
EXPECT_TRUE([controller_ dropShadowView]); |
EXPECT_TRUE([controller_ drawDropShadow]); |
EXPECT_NSEQ([controller_ view], [[controller_ dropShadowView] superview]); |
@@ -146,9 +149,8 @@ IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, NoShadowNTP) { |
// Verify that the shadow is hidden when hiding the overlay. |
IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HideShadow) { |
- chrome::search::Mode mode; |
- mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS; |
- instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ 10, INSTANT_SIZE_PERCENT); |
EXPECT_TRUE([controller_ dropShadowView]); |
[controller_ onActivateTabWithContents:web_contents_.get()]; |
@@ -157,14 +159,15 @@ IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HideShadow) { |
// Verify that the web contents is not hidden when just the height changes. |
IN_PROC_BROWSER_TEST_F(OverlayableContentsControllerTest, HeightChangeNoHide) { |
- chrome::search::Mode mode; |
- mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS; |
- instant_overlay_model_.SetOverlayState(mode, 10, INSTANT_SIZE_PERCENT); |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ 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); |
+ |
+ instant_overlay_model_->SetOverlayState(web_contents_.get(), |
+ 11, INSTANT_SIZE_PERCENT); |
EXPECT_EQ(1, visibility_changed_count_); |
} |