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

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: groby's review Created 6 years, 10 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/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..0b7f6e3425212f07b6c3ddef79b48142064c0035
--- /dev/null
+++ b/chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm
@@ -0,0 +1,60 @@
+// 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"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/site_instance.h"
+
+class TranslateBubbleControllerTest : public CocoaProfileTest {
+ public:
+ virtual void SetUp() OVERRIDE {
+ CocoaProfileTest::SetUp();
+ site_instance_ = content::SiteInstance::Create(profile());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ CocoaProfileTest::TearDown();
+ }
+
+ 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 = [TranslateBubbleController current];
+ EXPECT_FALSE(bubble);
+
+ [TranslateBubbleController showForParentWindow:bwc
+ webContents:webContents
+ step:step
+ errorType:TranslateErrors::NONE];
+ bubble = [TranslateBubbleController current];
+ EXPECT_TRUE(bubble);
+
+ [bubble close];
+ base::MessageLoopForUI::current()->RunUntilIdle();
groby-ooo-7-16 2014/02/26 03:13:58 You probably want chrome::testing::NSRunLoopRunAll
hajimehoshi 2014/02/26 09:18:18 Hmm, NSRunLoopRunAllPending couldn't work for this
groby-ooo-7-16 2014/02/27 19:19:02 Odd. I can't see anything that would require PostT
hajimehoshi 2014/02/28 04:25:22 Sure. I'll comment about this.
+ bubble = [TranslateBubbleController current];
+ EXPECT_FALSE(bubble);
+}

Powered by Google App Engine
This is Rietveld 408576698