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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 #include "chrome/common/url_constants.h"
13 #include "content/public/browser/site_instance.h"
14
15 class TranslateBubbleControllerTest : public CocoaProfileTest {
16 public:
17 virtual void SetUp() OVERRIDE {
18 CocoaProfileTest::SetUp();
19 site_instance_ = content::SiteInstance::Create(profile());
20 }
21
22 virtual void TearDown() OVERRIDE {
23 CocoaProfileTest::TearDown();
24 }
25
26 content::WebContents* AppendToTabStrip() {
27 content::WebContents* web_contents = content::WebContents::Create(
28 content::WebContents::CreateParams(profile(), site_instance_.get()));
29 browser()->tab_strip_model()->AppendWebContents(
30 web_contents, /*foreground=*/true);
31 return web_contents;
32 }
33
34 private:
35 scoped_refptr<content::SiteInstance> site_instance_;
36 };
37
38 TEST_F(TranslateBubbleControllerTest, ShowAndClose) {
39 NSWindow* nativeWindow = browser()->window()->GetNativeWindow();
40 BrowserWindowController* bwc =
41 [BrowserWindowController browserWindowControllerForWindow:nativeWindow];
42 content::WebContents* webContents = AppendToTabStrip();
43 TranslateTabHelper::TranslateStep step =
44 TranslateTabHelper::BEFORE_TRANSLATE;
45
46 TranslateBubbleController* bubble = [TranslateBubbleController current];
47 EXPECT_FALSE(bubble);
48
49 [TranslateBubbleController showForParentWindow:bwc
50 webContents:webContents
51 step:step
52 errorType:TranslateErrors::NONE];
53 bubble = [TranslateBubbleController current];
54 EXPECT_TRUE(bubble);
55
56 [bubble close];
57 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.
58 bubble = [TranslateBubbleController current];
59 EXPECT_FALSE(bubble);
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698