OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 "base/message_loop.h" | |
6 #include "base/utf_string_conversions.h" | |
7 #include "chrome/browser/ui/views/generic_info_view.h" | |
8 #include "grit/chromium_strings.h" | |
9 #include "grit/generated_resources.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 #include "ui/base/l10n/l10n_util.h" | |
12 #include "ui/views/controls/label.h" | |
13 #include "ui/views/controls/textfield/textfield.h" | |
14 #include "ui/views/widget/widget.h" | |
15 | |
16 // This class is only used on windows for now. | |
17 #if defined(OS_WIN) | |
18 | |
19 class GenericInfoViewTest : public testing::Test { | |
20 private: | |
21 MessageLoopForUI message_loop_; | |
22 }; | |
23 | |
24 TEST_F(GenericInfoViewTest, GenericInfoView) { | |
25 const string16 kName = ASCIIToUTF16("Name"); | |
26 const string16 kValue = ASCIIToUTF16("Value"); | |
27 | |
28 views::Widget* widget = new views::Widget; | |
29 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | |
30 params.bounds = gfx::Rect(0, 0, 100, 100); | |
31 widget->Init(params); | |
32 views::View* root_view = widget->GetRootView(); | |
33 | |
34 GenericInfoView* view1 = new GenericInfoView(1); | |
35 root_view->AddChildView(view1); | |
36 view1->SetName(0, kName); | |
37 view1->SetValue(0, kValue); | |
38 EXPECT_EQ(kName, view1->name_views_[0]->text()); | |
39 EXPECT_EQ(kValue, view1->value_views_[0]->text()); | |
40 view1->ClearValues(); | |
41 EXPECT_TRUE(view1->value_views_[0]->text().empty()); | |
42 | |
43 // Test setting values by localized string id. | |
44 static int kNameIds[] = { | |
45 IDS_PRODUCT_NAME, | |
46 IDS_PRODUCT_DESCRIPTION | |
47 }; | |
48 GenericInfoView* view2 = new GenericInfoView(ARRAYSIZE(kNameIds), kNameIds); | |
49 root_view->AddChildView(view2); | |
50 | |
51 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | |
52 string16 product_desc = l10n_util::GetStringUTF16(IDS_PRODUCT_DESCRIPTION); | |
53 EXPECT_EQ(product_name, view2->name_views_[0]->text()); | |
54 EXPECT_EQ(product_desc, view2->name_views_[1]->text()); | |
55 widget->CloseNow(); | |
56 } | |
57 #endif // OS_WIN | |
OLD | NEW |