| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/status/clock_menu_button.h" | 5 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 #include "chrome/browser/chromeos/frame/browser_view.h" | 9 #include "chrome/browser/chromeos/frame/browser_view.h" |
| 10 #include "chrome/browser/chromeos/status/status_area_view.h" | |
| 11 #include "chrome/browser/chromeos/system/timezone_settings.h" | 10 #include "chrome/browser/chromeos/system/timezone_settings.h" |
| 12 #include "chrome/browser/chromeos/view_ids.h" | 11 #include "chrome/browser/chromeos/view_ids.h" |
| 13 #include "chrome/browser/prefs/pref_member.h" | 12 #include "chrome/browser/prefs/pref_member.h" |
| 14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "unicode/calendar.h" | 17 #include "unicode/calendar.h" |
| 19 #include "unicode/timezone.h" | 18 #include "unicode/timezone.h" |
| 20 | 19 |
| 21 namespace chromeos { | 20 namespace chromeos { |
| 22 | 21 |
| 23 class ClockMenuButtonTest : public InProcessBrowserTest { | 22 class ClockMenuButtonTest : public InProcessBrowserTest { |
| 24 protected: | 23 protected: |
| 25 ClockMenuButtonTest() : InProcessBrowserTest() {} | 24 ClockMenuButtonTest() : InProcessBrowserTest() {} |
| 26 virtual void SetUpInProcessBrowserTestFixture() { | 25 virtual void SetUpInProcessBrowserTestFixture() { |
| 27 // This test requires actual libcros, but InProcessBrowserTest has set | 26 // This test requires actual libcros, but InProcessBrowserTest has set |
| 28 // to use stub, so reset it here. | 27 // to use stub, so reset it here. |
| 29 CrosLibrary::Get()->GetTestApi()->ResetUseStubImpl(); | 28 CrosLibrary::Get()->GetTestApi()->ResetUseStubImpl(); |
| 30 } | 29 } |
| 31 ClockMenuButton* GetClockMenuButton() { | 30 ClockMenuButton* GetClockMenuButton() { |
| 32 BrowserView* view = static_cast<BrowserView*>(browser()->window()); | 31 BrowserView* view = static_cast<BrowserView*>(browser()->window()); |
| 33 return static_cast<StatusAreaView*>(view-> | 32 return static_cast<ClockMenuButton*>(view->GetViewByID( |
| 34 GetViewByID(VIEW_ID_STATUS_AREA))->clock_view(); | 33 VIEW_ID_STATUS_BUTTON_CLOCK)); |
| 35 } | 34 } |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 IN_PROC_BROWSER_TEST_F(ClockMenuButtonTest, TimezoneTest) { | 37 IN_PROC_BROWSER_TEST_F(ClockMenuButtonTest, TimezoneTest) { |
| 39 ClockMenuButton* clock = GetClockMenuButton(); | 38 ClockMenuButton* clock = GetClockMenuButton(); |
| 40 ASSERT_TRUE(clock != NULL); | 39 ASSERT_TRUE(clock != NULL); |
| 41 | 40 |
| 42 // Update timezone and make sure clock text changes. | 41 // Update timezone and make sure clock text changes. |
| 43 scoped_ptr<icu::TimeZone> timezone_first(icu::TimeZone::createTimeZone( | 42 scoped_ptr<icu::TimeZone> timezone_first(icu::TimeZone::createTimeZone( |
| 44 icu::UnicodeString::fromUTF8("Asia/Hong_Kong"))); | 43 icu::UnicodeString::fromUTF8("Asia/Hong_Kong"))); |
| 45 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_first); | 44 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_first); |
| 46 string16 text_before = clock->text(); | 45 string16 text_before = clock->text(); |
| 47 scoped_ptr<icu::TimeZone> timezone_second(icu::TimeZone::createTimeZone( | 46 scoped_ptr<icu::TimeZone> timezone_second(icu::TimeZone::createTimeZone( |
| 48 icu::UnicodeString::fromUTF8("Pacific/Samoa"))); | 47 icu::UnicodeString::fromUTF8("Pacific/Samoa"))); |
| 49 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_second); | 48 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_second); |
| 50 string16 text_after = clock->text(); | 49 string16 text_after = clock->text(); |
| 51 EXPECT_NE(text_before, text_after); | 50 EXPECT_NE(text_before, text_after); |
| 52 } | 51 } |
| 53 | 52 |
| 54 } // namespace chromeos | 53 } // namespace chromeos |
| OLD | NEW |