summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/accessibility_event_router_gtk_unittest.cc
blob: 3b9998047c4ecfdbbf9c3144e495c5d3a28da0a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/gtk/accessibility_event_router_gtk.h"
#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"

class AccessibilityEventRouterGtkTest : public testing::Test {
 protected:
  AccessibilityEventRouterGtkTest() { }
};

TEST_F(AccessibilityEventRouterGtkTest, AddRootWidgetTwice) {
  AccessibilityEventRouterGtk* event_router =
      AccessibilityEventRouterGtk::GetInstance();
  TestingProfile profile;

  GtkWidget* widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  bool found = false;
  event_router->FindWidget(widget, NULL, &found);
  EXPECT_FALSE(found);

  event_router->AddRootWidget(widget, &profile);
  event_router->FindWidget(widget, NULL, &found);
  EXPECT_TRUE(found);

  event_router->AddRootWidget(widget, &profile);
  event_router->FindWidget(widget, NULL, &found);
  EXPECT_TRUE(found);

  event_router->RemoveRootWidget(widget);
  event_router->FindWidget(widget, NULL, &found);
  EXPECT_TRUE(found);

  event_router->RemoveRootWidget(widget);
  event_router->FindWidget(widget, NULL, &found);
  EXPECT_FALSE(found);

  gtk_widget_destroy(widget);
};