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

Unified Diff: ui/views/view_unittest.cc

Issue 258063009: retry r266622: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert Label changes completely Created 6 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 834f79cca55cbd7e44b11c9bc01c5c0c04b27b7e..b1bcb6ac817d358e23d22348a9b91bb7d7d65fcf 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -203,7 +203,7 @@ typedef ViewsTestBase ViewTest;
// A derived class for testing purpose.
class TestView : public View {
public:
- TestView() : View(), delete_on_pressed_(false) {}
+ TestView() : View(), delete_on_pressed_(false), native_theme_(NULL) {}
virtual ~TestView() {}
// Reset all test state
@@ -244,6 +244,9 @@ class TestView : public View {
virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
+ virtual void OnNativeThemeChanged(const ui::NativeTheme* native_theme)
+ OVERRIDE;
+
// OnBoundsChanged.
bool did_change_bounds_;
gfx::Rect new_bounds_;
@@ -267,6 +270,9 @@ class TestView : public View {
// Accelerators.
std::map<ui::Accelerator, int> accelerator_count_map_;
+
+ // Native theme.
+ const ui::NativeTheme* native_theme_;
};
// A view subclass that consumes all Gesture events for testing purposes.
@@ -3619,4 +3625,43 @@ TEST_F(ViewTest, UpdateViewStorageOnDelete) {
EXPECT_TRUE(view_storage->RetrieveView(storage_id) == NULL);
}
+////////////////////////////////////////////////////////////////////////////////
+// NativeTheme
+////////////////////////////////////////////////////////////////////////////////
+
+void TestView::OnNativeThemeChanged(const ui::NativeTheme* native_theme) {
+ native_theme_ = native_theme;
+}
+
+TEST_F(ViewTest, OnNativeThemeChanged) {
+ TestView* test_view = new TestView();
+ EXPECT_FALSE(test_view->native_theme_);
+ TestView* test_view_child = new TestView();
+ EXPECT_FALSE(test_view_child->native_theme_);
+
+ // Child view added before the widget hierarchy exists should get the
+ // new native theme notification.
+ test_view->AddChildView(test_view_child);
+
+ scoped_ptr<Widget> widget(new Widget);
+ Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget->Init(params);
+
+ widget->GetRootView()->AddChildView(test_view);
+ EXPECT_TRUE(test_view->native_theme_);
+ EXPECT_EQ(widget->GetNativeTheme(), test_view->native_theme_);
+ EXPECT_TRUE(test_view_child->native_theme_);
+ EXPECT_EQ(widget->GetNativeTheme(), test_view_child->native_theme_);
+
+ // Child view added after the widget hierarchy exists should also get the
+ // notification.
+ TestView* test_view_child_2 = new TestView();
+ test_view->AddChildView(test_view_child_2);
+ EXPECT_TRUE(test_view_child_2->native_theme_);
+ EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_);
+
+ widget->CloseNow();
+}
+
} // namespace views
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698