clock_menu_button_browsertest.cc revision 4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7
1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/chromeos/status/clock_menu_button.h" 6 7#include "base/string_util.h" 8#include "chrome/browser/chromeos/cros/cros_library.h" 9#include "chrome/browser/chromeos/cros/system_library.h" 10#include "chrome/browser/chromeos/frame/browser_view.h" 11#include "chrome/browser/chromeos/status/status_area_view.h" 12#include "chrome/browser/chromeos/view_ids.h" 13#include "chrome/browser/prefs/pref_member.h" 14#include "chrome/browser/profile.h" 15#include "chrome/browser/ui/browser.h" 16#include "chrome/browser/ui/browser_window.h" 17#include "chrome/common/pref_names.h" 18#include "chrome/test/in_process_browser_test.h" 19#include "testing/gtest/include/gtest/gtest.h" 20#include "unicode/calendar.h" 21#include "unicode/timezone.h" 22 23namespace chromeos { 24 25class ClockMenuButtonTest : public InProcessBrowserTest { 26 protected: 27 ClockMenuButtonTest() : InProcessBrowserTest() {} 28 virtual void SetUpInProcessBrowserTestFixture() { 29 // This test requires actual libcros, but InProcessBrowserTest has set 30 // to use stub, so reset it here. 31 CrosLibrary::Get()->GetTestApi()->ResetUseStubImpl(); 32 } 33 ClockMenuButton* GetClockMenuButton() { 34 BrowserView* view = static_cast<BrowserView*>(browser()->window()); 35 return static_cast<StatusAreaView*>(view-> 36 GetViewByID(VIEW_ID_STATUS_AREA))->clock_view(); 37 } 38}; 39 40IN_PROC_BROWSER_TEST_F(ClockMenuButtonTest, TimezoneTest) { 41 ClockMenuButton* clock = GetClockMenuButton(); 42 ASSERT_TRUE(clock != NULL); 43 44 // Update timezone and make sure clock text changes. 45 scoped_ptr<icu::TimeZone> timezone_first(icu::TimeZone::createTimeZone( 46 icu::UnicodeString::fromUTF8("Asia/Hong_Kong"))); 47 CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone_first.get()); 48 std::wstring text_before = clock->text(); 49 scoped_ptr<icu::TimeZone> timezone_second(icu::TimeZone::createTimeZone( 50 icu::UnicodeString::fromUTF8("Pacific/Samoa"))); 51 CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone_second.get()); 52 std::wstring text_after = clock->text(); 53 EXPECT_NE(text_before, text_after); 54 55} 56 57} // namespace chromeos 58