Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 9 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
| 10 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 11 | 12 |
| 12 namespace ui { | 13 namespace ui { |
| 13 | 14 |
| 14 class ViewTest : public testing::Test { | 15 class ViewTest : public testing::Test { |
| 15 public: | 16 public: |
| 16 ViewTest() {} | 17 ViewTest() {} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 v.RemoveChildView(&child2, false); | 50 v.RemoveChildView(&child2, false); |
| 50 EXPECT_EQ(1, v.children_size()); | 51 EXPECT_EQ(1, v.children_size()); |
| 51 EXPECT_EQ(NULL, child2.parent()); | 52 EXPECT_EQ(NULL, child2.parent()); |
| 52 | 53 |
| 53 //v.RemoveAllChildViews(false); | 54 //v.RemoveAllChildViews(false); |
| 54 //EXPECT_TRUE(v.children_empty()); | 55 //EXPECT_TRUE(v.children_empty()); |
| 55 } | 56 } |
| 56 | 57 |
| 57 class ObserverView : public View { | 58 class ObserverView : public View { |
| 58 public: | 59 public: |
| 59 ObserverView() | 60 ObserverView() : view_added_(false), |
|
sky
2011/06/08 15:57:35
The old code is the correct indentation style. See
tfarina
2011/06/08 19:13:56
Done.
| |
| 60 : view_added_(false), | 61 view_removed_(false), |
| 61 view_removed_(false), | 62 subject_view_(NULL) {} |
| 62 subject_view_(NULL) {} | |
| 63 virtual ~ObserverView() {} | 63 virtual ~ObserverView() {} |
| 64 | 64 |
| 65 void ResetTestState() { | 65 void ResetTestState() { |
| 66 view_added_ = false; | 66 view_added_ = false; |
| 67 view_removed_ = false; | 67 view_removed_ = false; |
| 68 subject_view_ = NULL; | 68 subject_view_ = NULL; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Overridden from View: | 71 // Overridden from View: |
| 72 virtual void OnViewAdded(View* parent, View* child) { | 72 virtual void OnViewAdded(const View& parent, const View& child) OVERRIDE { |
| 73 subject_view_ = child; | |
| 74 view_added_ = true; | 73 view_added_ = true; |
| 75 view_removed_ = false; | 74 view_removed_ = false; |
| 75 subject_view_ = &child; | |
| 76 } | 76 } |
| 77 virtual void OnViewRemoved(View* parent, View* child) { | 77 virtual void OnViewRemoved(const View& parent, const View& child) OVERRIDE { |
| 78 subject_view_ = child; | 78 view_added_ = false; |
| 79 view_removed_ = true; | 79 view_removed_ = true; |
| 80 view_added_ = false; | 80 subject_view_ = &child; |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool view_added() const { return view_added_; } | 83 bool view_added() const { return view_added_; } |
| 84 bool view_removed() const { return view_removed_; } | 84 bool view_removed() const { return view_removed_; } |
| 85 View* subject_view() const { return subject_view_; } | 85 View* subject_view() const { return subject_view_; } |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 bool view_added_; | 88 bool view_added_; |
| 89 bool view_removed_; | 89 bool view_removed_; |
| 90 View* subject_view_; | 90 View* subject_view_; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 | 195 |
| 196 TEST_F(ViewTest, EventHandlers) { | 196 TEST_F(ViewTest, EventHandlers) { |
| 197 | 197 |
| 198 } | 198 } |
| 199 | 199 |
| 200 TEST_F(ViewTest, Painting) { | 200 TEST_F(ViewTest, Painting) { |
| 201 | 201 |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace ui | 204 } // namespace ui |
| OLD | NEW |