Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" | |
| 6 | |
| 7 #include "base/message_loop/message_loop.h" | |
| 8 #import "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/browser_window.h" | |
| 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | |
| 11 #import "chrome/browser/ui/cocoa/cocoa_profile_test.h" | |
| 12 #import "chrome/browser/ui/cocoa/run_loop_testing.h" | |
| 13 #include "chrome/common/url_constants.h" | |
| 14 #include "content/public/browser/site_instance.h" | |
| 15 | |
| 16 @implementation BrowserWindowController (ForTesting) | |
| 17 | |
| 18 - (TranslateBubbleController*)translateBubbleController{ | |
| 19 return translateBubbleController_; | |
| 20 } | |
| 21 | |
| 22 @end | |
| 23 | |
| 24 class TranslateBubbleControllerTest : public CocoaProfileTest { | |
| 25 public: | |
| 26 virtual void SetUp() OVERRIDE { | |
| 27 CocoaProfileTest::SetUp(); | |
| 28 site_instance_ = content::SiteInstance::Create(profile()); | |
| 29 } | |
| 30 | |
| 31 virtual void TearDown() OVERRIDE { | |
|
Robert Sesek
2014/02/27 20:45:01
Don't need to OVERRIDE if there is no work to be d
hajimehoshi
2014/02/28 04:25:22
Done.
| |
| 32 CocoaProfileTest::TearDown(); | |
| 33 } | |
| 34 | |
| 35 content::WebContents* AppendToTabStrip() { | |
| 36 content::WebContents* web_contents = content::WebContents::Create( | |
| 37 content::WebContents::CreateParams(profile(), site_instance_.get())); | |
| 38 browser()->tab_strip_model()->AppendWebContents( | |
| 39 web_contents, /*foreground=*/true); | |
| 40 return web_contents; | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 scoped_refptr<content::SiteInstance> site_instance_; | |
| 45 }; | |
| 46 | |
| 47 TEST_F(TranslateBubbleControllerTest, ShowAndClose) { | |
| 48 NSWindow* nativeWindow = browser()->window()->GetNativeWindow(); | |
| 49 BrowserWindowController* bwc = | |
| 50 [BrowserWindowController browserWindowControllerForWindow:nativeWindow]; | |
| 51 content::WebContents* webContents = AppendToTabStrip(); | |
| 52 TranslateTabHelper::TranslateStep step = | |
| 53 TranslateTabHelper::BEFORE_TRANSLATE; | |
| 54 | |
| 55 TranslateBubbleController* bubble = [bwc translateBubbleController]; | |
| 56 EXPECT_FALSE(bubble); | |
| 57 | |
| 58 [bwc showTranslateBubbleForWebContents:webContents | |
| 59 step:step | |
| 60 errorType:TranslateErrors::NONE]; | |
| 61 bubble = [bwc translateBubbleController]; | |
| 62 EXPECT_TRUE(bubble); | |
| 63 | |
| 64 [bubble close]; | |
| 65 base::MessageLoopForUI::current()->RunUntilIdle(); | |
| 66 bubble = [bwc translateBubbleController]; | |
| 67 EXPECT_FALSE(bubble); | |
| 68 } | |
| OLD | NEW |