| Index: chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm
|
| diff --git a/chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9fa070eadd7dbaa82022ae611e533911195f4507
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2014 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 "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h"
|
| +
|
| +#include "base/message_loop/message_loop.h"
|
| +#import "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| +#import "chrome/browser/ui/cocoa/browser_window_controller.h"
|
| +#import "chrome/browser/ui/cocoa/cocoa_profile_test.h"
|
| +#import "chrome/browser/ui/cocoa/info_bubble_window.h"
|
| +#import "chrome/browser/ui/cocoa/run_loop_testing.h"
|
| +#include "chrome/common/url_constants.h"
|
| +#include "content/public/browser/site_instance.h"
|
| +
|
| +@implementation BrowserWindowController (ForTesting)
|
| +
|
| +- (TranslateBubbleController*)translateBubbleController{
|
| + return translateBubbleController_;
|
| +}
|
| +
|
| +@end
|
| +
|
| +class TranslateBubbleControllerTest : public CocoaProfileTest {
|
| + public:
|
| + virtual void SetUp() OVERRIDE {
|
| + CocoaProfileTest::SetUp();
|
| + site_instance_ = content::SiteInstance::Create(profile());
|
| + }
|
| +
|
| + content::WebContents* AppendToTabStrip() {
|
| + content::WebContents* web_contents = content::WebContents::Create(
|
| + content::WebContents::CreateParams(profile(), site_instance_.get()));
|
| + browser()->tab_strip_model()->AppendWebContents(
|
| + web_contents, /*foreground=*/true);
|
| + return web_contents;
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<content::SiteInstance> site_instance_;
|
| +};
|
| +
|
| +TEST_F(TranslateBubbleControllerTest, ShowAndClose) {
|
| + NSWindow* nativeWindow = browser()->window()->GetNativeWindow();
|
| + BrowserWindowController* bwc =
|
| + [BrowserWindowController browserWindowControllerForWindow:nativeWindow];
|
| + content::WebContents* webContents = AppendToTabStrip();
|
| + TranslateTabHelper::TranslateStep step =
|
| + TranslateTabHelper::BEFORE_TRANSLATE;
|
| +
|
| + TranslateBubbleController* bubble = [bwc translateBubbleController];
|
| + EXPECT_FALSE(bubble);
|
| +
|
| + [bwc showTranslateBubbleForWebContents:webContents
|
| + step:step
|
| + errorType:TranslateErrors::NONE];
|
| + bubble = [bwc translateBubbleController];
|
| + EXPECT_TRUE(bubble);
|
| + InfoBubbleWindow* window = (InfoBubbleWindow*)[bubble window];
|
| + [window setAllowedAnimations:info_bubble::kAnimateNone];
|
| +
|
| + [bubble close];
|
| + chrome::testing::NSRunLoopRunAllPending();
|
| + bubble = [bwc translateBubbleController];
|
| + EXPECT_FALSE(bubble);
|
| +}
|
|
|