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

Side by Side Diff: chrome/browser/ui/cocoa/translate/translate_bubble_controller_unittest.mm

Issue 2262913002: fix TranslateBubble toggle off by omnibar icon Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" 5 #include "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #import "chrome/browser/ui/browser.h" 9 #import "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Switch to before translating view. 155 // Switch to before translating view.
156 [bubble() switchView: 156 [bubble() switchView:
157 (TranslateBubbleModel::ViewState::VIEW_STATE_BEFORE_TRANSLATE)]; 157 (TranslateBubbleModel::ViewState::VIEW_STATE_BEFORE_TRANSLATE)];
158 158
159 EXPECT_TRUE(bubble()); 159 EXPECT_TRUE(bubble());
160 160
161 CloseBubble(); 161 CloseBubble();
162 EXPECT_FALSE(bubble()); 162 EXPECT_FALSE(bubble());
163 } 163 }
164 164
165 TEST_F(TranslateBubbleControllerTest, CloseRegistersDecline) { 165 TEST_F(TranslateBubbleControllerTest, CloseRegistersDecline1) {
166 const char kDeclineTranslateDismissUI[] = 166 const char kDeclineTranslateDismissUI[] =
167 "Translate.DeclineTranslateDismissUI"; 167 "Translate.DeclineTranslateDismissUI";
168 const char kDeclineTranslate[] = "Translate.DeclineTranslate"; 168 const char kDeclineTranslate[] = "Translate.DeclineTranslate";
169 169
170 // A simple close without any interactions registers as a dismissal. 170 // A simple close without any interactions registers as a dismissal.
171 { 171 base::HistogramTester histogram_tester;
172 base::HistogramTester histogram_tester; 172 ShowBubble();
173 ShowBubble(); 173 CloseBubble();
174 CloseBubble(); 174 histogram_tester.ExpectTotalCount(kDeclineTranslateDismissUI, 1);
175 histogram_tester.ExpectTotalCount(kDeclineTranslateDismissUI, 1); 175 histogram_tester.ExpectTotalCount(kDeclineTranslate, 0);
176 histogram_tester.ExpectTotalCount(kDeclineTranslate, 0); 176 }
177 }
178 177
178 TEST_F(TranslateBubbleControllerTest, CloseRegistersDecline2) {
179 const char kDeclineTranslateDismissUI[] =
180 "Translate.DeclineTranslateDismissUI";
181 const char kDeclineTranslate[] = "Translate.DeclineTranslate";
179 // A close while pressing e.g. 'x', registers as decline. 182 // A close while pressing e.g. 'x', registers as decline.
180 { 183 base::HistogramTester histogram_tester;
181 base::HistogramTester histogram_tester; 184 ShowBubble();
182 ShowBubble(); 185 [bubble() handleCloseButtonPressed:nil];
183 [bubble() handleCloseButtonPressed:nil];
184 186
185 CloseBubble(); 187 CloseBubble();
186 histogram_tester.ExpectTotalCount(kDeclineTranslateDismissUI, 0); 188 histogram_tester.ExpectTotalCount(kDeclineTranslateDismissUI, 0);
187 histogram_tester.ExpectTotalCount(kDeclineTranslate, 1); 189 histogram_tester.ExpectTotalCount(kDeclineTranslate, 1);
188 }
189 } 190 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698