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

Side by Side Diff: chrome/browser/chromeos/status/clock_menu_button_browsertest.cc

Issue 8600001: Fixes bug where clock button wasn't updating in response to a timezone (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge and allow NULL Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/status_area_view_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/timezone_settings.h" 10 #include "chrome/browser/chromeos/system/timezone_settings.h"
11 #include "chrome/browser/chromeos/view_ids.h" 11 #include "chrome/browser/chromeos/view_ids.h"
12 #include "chrome/browser/prefs/pref_member.h" 12 #include "chrome/browser/prefs/pref_member.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "unicode/calendar.h" 17 #include "unicode/calendar.h"
18 #include "unicode/timezone.h" 18 #include "unicode/timezone.h"
19 19
20 #if defined(USE_AURA)
21 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
22 #endif
23
20 namespace chromeos { 24 namespace chromeos {
21 25
22 class ClockMenuButtonTest : public InProcessBrowserTest { 26 class ClockMenuButtonTest : public InProcessBrowserTest {
23 protected: 27 protected:
24 ClockMenuButtonTest() : InProcessBrowserTest() {} 28 ClockMenuButtonTest() : InProcessBrowserTest() {}
25 virtual void SetUpInProcessBrowserTestFixture() { 29 virtual void SetUpInProcessBrowserTestFixture() {
26 // This test requires actual libcros, but InProcessBrowserTest has set 30 // This test requires actual libcros, but InProcessBrowserTest has set
27 // to use stub, so reset it here. 31 // to use stub, so reset it here.
28 CrosLibrary::Get()->GetTestApi()->ResetUseStubImpl(); 32 CrosLibrary::Get()->GetTestApi()->ResetUseStubImpl();
29 } 33 }
30 ClockMenuButton* GetClockMenuButton() { 34 const ClockMenuButton* GetClockMenuButton() {
31 BrowserView* view = static_cast<BrowserView*>(browser()->window()); 35 const views::View* parent = NULL;
32 return static_cast<ClockMenuButton*>(view->GetViewByID( 36 #if defined(USE_AURA)
37 parent = ChromeShellDelegate::instance()->GetStatusArea();
38 #else
39 parent = static_cast<const BrowserView*>(browser()->window());
40 #endif
41 return static_cast<const ClockMenuButton*>(parent->GetViewByID(
33 VIEW_ID_STATUS_BUTTON_CLOCK)); 42 VIEW_ID_STATUS_BUTTON_CLOCK));
34 } 43 }
35 }; 44 };
36 45
37 IN_PROC_BROWSER_TEST_F(ClockMenuButtonTest, TimezoneTest) { 46 IN_PROC_BROWSER_TEST_F(ClockMenuButtonTest, TimezoneTest) {
38 ClockMenuButton* clock = GetClockMenuButton(); 47 const ClockMenuButton* clock = GetClockMenuButton();
39 ASSERT_TRUE(clock != NULL); 48 ASSERT_TRUE(clock != NULL);
40 49
41 // Update timezone and make sure clock text changes. 50 // Update timezone and make sure clock text changes.
42 scoped_ptr<icu::TimeZone> timezone_first(icu::TimeZone::createTimeZone( 51 scoped_ptr<icu::TimeZone> timezone_first(icu::TimeZone::createTimeZone(
43 icu::UnicodeString::fromUTF8("Asia/Hong_Kong"))); 52 icu::UnicodeString::fromUTF8("Asia/Hong_Kong")));
44 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_first); 53 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_first);
45 string16 text_before = clock->text(); 54 string16 text_before = clock->text();
46 scoped_ptr<icu::TimeZone> timezone_second(icu::TimeZone::createTimeZone( 55 scoped_ptr<icu::TimeZone> timezone_second(icu::TimeZone::createTimeZone(
47 icu::UnicodeString::fromUTF8("Pacific/Samoa"))); 56 icu::UnicodeString::fromUTF8("Pacific/Samoa")));
48 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_second); 57 system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_second);
49 string16 text_after = clock->text(); 58 string16 text_after = clock->text();
50 EXPECT_NE(text_before, text_after); 59 EXPECT_NE(text_before, text_after);
51 } 60 }
52 61
53 } // namespace chromeos 62 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/status_area_view_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698