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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm

Issue 2555783002: [Mac] Ensure Omnibox text is always right-aligned in RTL (Closed)
Patch Set: User ScopedForceRTLMac for RTL test setup Created 4 years 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/omnibox/omnibox_view_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm
index f3d584163744b7e88bfe357c62590294be108e84..1038d79585e861193def234d0385bb39af4d8bd2 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h"
+#include "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h"
#include "chrome/browser/ui/omnibox/chrome_omnibox_client.h"
#include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h"
@@ -176,3 +177,65 @@ TEST_F(OmniboxViewMacTest, UpDownArrow) {
view.OnDoCommandBySelector(@selector(moveUp:));
EXPECT_EQ(-1, model->up_or_down_count());
}
+
+TEST_F(OmniboxViewMacTest, WritingDirectionLTR) {
+ TestingToolbarModelDelegate delegate;
+ ToolbarModelImpl toolbar_model(&delegate, 32 * 1024);
+ TestingOmniboxEditController edit_controller(&toolbar_model);
+ OmniboxViewMac view(&edit_controller, profile(), NULL, NULL);
+
+ // This is deleted by the omnibox view.
+ MockOmniboxEditModel* model =
+ new MockOmniboxEditModel(&view, &edit_controller, profile());
+ MockOmniboxPopupView popup_view;
+ OmniboxPopupModel popup_model(&popup_view, model);
+
+ model->OnSetFocus(true);
+ SetModel(&view, model);
+ view.SetUserText(base::ASCIIToUTF16("foo.com"));
+ model->OnChanged();
+
+ base::scoped_nsobject<NSMutableAttributedString> string(
+ [[NSMutableAttributedString alloc] initWithString:@"foo.com"]);
+ view.ApplyTextStyle(string);
+
+ NSParagraphStyle* paragraphStyle =
+ [string attribute:NSParagraphStyleAttributeName
+ atIndex:0
+ effectiveRange:NULL];
+ DCHECK(paragraphStyle);
+ EXPECT_EQ(paragraphStyle.alignment, NSLeftTextAlignment);
+ EXPECT_EQ(paragraphStyle.baseWritingDirection, NSWritingDirectionLeftToRight);
+}
+
+TEST_F(OmniboxViewMacTest, WritingDirectionRTL) {
+ cocoa_l10n_util::ScopedForceRTLMac rtl;
+
+ TestingToolbarModelDelegate delegate;
+ ToolbarModelImpl toolbar_model(&delegate, 32 * 1024);
+ TestingOmniboxEditController edit_controller(&toolbar_model);
+ OmniboxViewMac view(&edit_controller, profile(), NULL, NULL);
+
+ // This is deleted by the omnibox view.
+ MockOmniboxEditModel* model =
+ new MockOmniboxEditModel(&view, &edit_controller, profile());
+ MockOmniboxPopupView popup_view;
+ OmniboxPopupModel popup_model(&popup_view, model);
+
+ model->OnSetFocus(true);
+ SetModel(&view, model);
+ view.SetUserText(base::ASCIIToUTF16("foo.com"));
+ model->OnChanged();
+
+ base::scoped_nsobject<NSMutableAttributedString> string(
+ [[NSMutableAttributedString alloc] initWithString:@"foo.com"]);
+ view.ApplyTextStyle(string);
+
+ NSParagraphStyle* paragraphStyle =
+ [string attribute:NSParagraphStyleAttributeName
+ atIndex:0
+ effectiveRange:NULL];
+ DCHECK(paragraphStyle);
+ EXPECT_EQ(paragraphStyle.alignment, NSRightTextAlignment);
+ EXPECT_EQ(paragraphStyle.baseWritingDirection, NSWritingDirectionLeftToRight);
+}
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698