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

Unified Diff: chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm

Issue 151283006: Mac OS X: Show the Translate icon on Omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue-307352-translate-bubble-2
Patch Set: Use kAnimateNone Created 6 years, 9 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/ui/cocoa/translate/translate_bubble_controller.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « chrome/browser/ui/cocoa/translate/translate_bubble_controller.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698