Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / libgtk2ui / x11_input_method_context_impl_gtk2_unittest.cc
blobc4612f050fdc368b4c31ae7708714fe66a1ca93c
1 // Copyright 2013 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.
5 #include "chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace libgtk2ui {
12 class X11InputMethodContextImplGtk2FriendTest : public testing::Test {
15 TEST_F(X11InputMethodContextImplGtk2FriendTest, GtkCommitSignalTrap) {
16 libgtk2ui::X11InputMethodContextImplGtk2::GtkCommitSignalTrap trap;
18 // Test the initial state.
19 EXPECT_FALSE(trap.IsSignalCaught());
20 EXPECT_FALSE(trap.Trap(base::string16()));
21 EXPECT_FALSE(trap.IsSignalCaught());
23 // Cases which don't match the target keyval.
24 trap.StartTrap('t');
25 EXPECT_FALSE(trap.Trap(base::UTF8ToUTF16("T")));
26 EXPECT_FALSE(trap.IsSignalCaught());
27 EXPECT_FALSE(trap.Trap(base::UTF8ToUTF16("true")));
28 EXPECT_FALSE(trap.IsSignalCaught());
30 // Do not catch when the trap is not activated.
31 trap.StopTrap();
32 EXPECT_FALSE(trap.Trap(base::UTF8ToUTF16("t")));
33 EXPECT_FALSE(trap.IsSignalCaught());
35 // Successive calls don't break anything.
36 trap.StopTrap();
37 trap.StopTrap();
38 EXPECT_FALSE(trap.Trap(base::UTF8ToUTF16("t")));
39 EXPECT_FALSE(trap.IsSignalCaught());
40 trap.StartTrap('f');
41 trap.StartTrap('t');
42 EXPECT_TRUE(trap.Trap(base::UTF8ToUTF16("t")));
43 EXPECT_TRUE(trap.IsSignalCaught());
45 // StartTrap() resets the state.
46 trap.StartTrap('t');
47 EXPECT_FALSE(trap.IsSignalCaught());
48 // Many times calls to Trap() are okay.
49 EXPECT_FALSE(trap.Trap(base::UTF8ToUTF16("f")));
50 EXPECT_FALSE(trap.IsSignalCaught());
51 EXPECT_TRUE(trap.Trap(base::UTF8ToUTF16("t")));
52 EXPECT_TRUE(trap.IsSignalCaught());
55 } // namespace libgtk2ui