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 "ui/views/test/test_widget_observer.h" 6 7 #include "base/logging.h" 8 #include "ui/views/widget/widget.h" 9 10 namespace views { 11 namespace test { 12 13 TestWidgetObserver::TestWidgetObserver(Widget* widget) 14 : widget_(widget) { 15 widget_->AddObserver(this); 16 } 17 18 TestWidgetObserver::~TestWidgetObserver() { 19 if (widget_) 20 widget_->RemoveObserver(this); 21 } 22 23 void TestWidgetObserver::OnWidgetDestroying(Widget* widget) { 24 DCHECK_EQ(widget_, widget); 25 widget_ = NULL; 26 } 27 28 } // namespace test 29 } // namespace views 30