Bug 90248 - [Platform-ChromiumMac] Introduce LocaleMac class
Summary: [Platform-ChromiumMac] Introduce LocaleMac class
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: yosin
URL:
Keywords:
Depends on: 90752
Blocks: 90237
  Show dependency treegraph
 
Reported: 2012-06-28 23:37 PDT by yosin
Modified: 2012-07-09 23:49 PDT (History)
2 users (show)

See Also:


Attachments
Patch 1 (31.30 KB, patch)
2012-07-09 01:30 PDT, yosin
no flags Details | Formatted Diff | Diff
Patch 2 (31.38 KB, patch)
2012-07-09 01:33 PDT, yosin
no flags Details | Formatted Diff | Diff
Patch 3 (30.73 KB, patch)
2012-07-09 18:59 PDT, yosin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description yosin 2012-06-28 23:37:24 PDT
For unit testing, we would like to have LocaleMac class as of LocaleICU and LocaleWin to use specific locale rather than system default locale.
Comment 1 yosin 2012-07-09 01:30:09 PDT
Created attachment 151212 [details]
Patch 1
Comment 2 yosin 2012-07-09 01:33:21 PDT
Created attachment 151214 [details]
Patch 2
Comment 3 yosin 2012-07-09 01:34:12 PDT
Comment on attachment 151214 [details]
Patch 2

Could you review this patch?
Thanks in advance.
Comment 4 Kent Tamura 2012-07-09 03:45:35 PDT
Comment on attachment 151214 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=151214&action=review

> Source/WebCore/platform/text/mac/LocaleMac.mm:83
> +        return numeric_limits<double>::quiet_NaN();

We should prepend std:: to numeric_limits<>.

> Source/WebCore/platform/text/mac/LocaleMac.mm:181
> -        // weekdayName starts with Monday.
> -        labels.append(WTF::weekdayName[(i + 6) % 7]);
> +        m_weekDayShortLabels.append(WTF::weekdayName[(i + 6) % 7]);

Do not remove the comment.

> Source/WebKit/chromium/tests/LocaleMacTest.cpp:18
> + *     * Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + *     * Redistributions in binary form must reproduce the above
> + * copyright notice, this list of conditions and the following disclaimer
> + * in the documentation and/or other materials provided with the
> + * distribution.
> + *     * Neither the name of Google Inc. nor the names of its
> + * contributors may be used to endorse or promote products derived from
> + * this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

Please use the correct license header.

> Source/WebKit/chromium/tests/LocaleMacTest.cpp:147
> +    UChar frDecember[] = { 'd', 0xE9, 'c', 'e', 'm', 'b', 'r', 'e', 0 };
> +    EXPECT_STREQ(String(frDecember).utf8().data(), monthLabel("fr_FR", December).utf8().data());

The conversions for UChar -> String- > UTF8 CString is redundant.  Why don't you specify EXPECT_STREQ("d\xC3\xA9cembre", ...?

> Source/WebKit/chromium/tests/LocaleMacTest.cpp:154
> +    UChar jaJanuary[] = { '1', 0x6708, 0 };
> +    EXPECT_STREQ(String(jaJanuary).utf8().data(), monthLabel("ja_JP", January).utf8().data());
> +    UChar jaJune[] = { '6', 0x6708, 0 };
> +    EXPECT_STREQ(String(jaJune).utf8().data(), monthLabel("ja_JP", June).utf8().data());
> +    UChar jaDecember[] = { '1', '2', 0x6708, 0 };
> +    EXPECT_STREQ(String(jaDecember).utf8().data(), monthLabel("ja_JP", December).utf8().data());

ditto.

> Source/WebKit/chromium/tests/LocaleMacTest.cpp:172
> +    UChar jaSunday[] = { 0x65E5, 0 };
> +    EXPECT_STREQ(String(jaSunday).utf8().data(), weekDayShortLabel("ja_JP", Sunday).utf8().data());
> +    UChar jaWednesday[] = { 0x6C34, 0 };
> +    EXPECT_STREQ(String(jaWednesday).utf8().data(), weekDayShortLabel("ja_JP", Wednesday).utf8().data());
> +    UChar jaSaturday[] = { 0x571F, 0 };
> +    EXPECT_STREQ(String(jaSaturday).utf8().data(), weekDayShortLabel("ja_JP", Saturday).utf8().data());

ditto.
Comment 5 yosin 2012-07-09 18:59:59 PDT
Created attachment 151384 [details]
Patch 3
Comment 6 yosin 2012-07-09 19:02:49 PDT
Comment on attachment 151384 [details]
Patch 3

Could you review this patch?
Thanks in advance.

== Changes since the last review ==
* Add "std::" to numeric_limits
* Restore a removed comment in weekDayShortLabels()
* Update copyright text in LocaleMacTest.cpp
* Use UTF-8 string literal in LocaleMacTest.cpp
Comment 7 Kent Tamura 2012-07-09 19:14:07 PDT
Comment on attachment 151384 [details]
Patch 3

Looks ok
Comment 8 yosin 2012-07-09 19:16:35 PDT
Comment on attachment 151384 [details]
Patch 3

Clearing flags on attachment: 151384

Committed r122184: <http://trac.webkit.org/changeset/122184>
Comment 9 yosin 2012-07-09 19:16:43 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Kent Tamura 2012-07-09 23:49:30 PDT
Comment on attachment 151384 [details]
Patch 3

View in context: https://bugs.webkit.org/attachment.cgi?id=151384&action=review

> Source/WebCore/platform/text/mac/LocaleMac.mm:63
> +    static LocaleMac* currentLocale = LocaleMac::create([NSLocale currentLocale]).leakPtr();

The return value of [NSLocale currentLocale] is id, not a string.