OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "headless/public/domains/types.h" | 6 #include "headless/public/domains/types.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace headless { | 9 namespace headless { |
10 | 10 |
11 TEST(TypesTest, IntegerProperty) { | 11 TEST(TypesTest, IntegerProperty) { |
12 std::unique_ptr<accessibility::GetAXNodeParams> object( | 12 std::unique_ptr<page::NavigateToHistoryEntryParams> object( |
13 accessibility::GetAXNodeParams::Builder().SetNodeId(123).Build()); | 13 page::NavigateToHistoryEntryParams::Builder().SetEntryId(123).Build()); |
14 EXPECT_TRUE(object); | 14 EXPECT_TRUE(object); |
15 EXPECT_EQ(123, object->GetNodeId()); | 15 EXPECT_EQ(123, object->GetEntryId()); |
16 | 16 |
17 std::unique_ptr<accessibility::GetAXNodeParams> clone(object->Clone()); | 17 std::unique_ptr<page::NavigateToHistoryEntryParams> clone(object->Clone()); |
18 EXPECT_TRUE(clone); | 18 EXPECT_TRUE(clone); |
19 EXPECT_EQ(123, clone->GetNodeId()); | 19 EXPECT_EQ(123, clone->GetEntryId()); |
20 } | 20 } |
21 | 21 |
22 TEST(TypesTest, IntegerPropertyParseError) { | 22 TEST(TypesTest, IntegerPropertyParseError) { |
23 const char* json = "{\"nodeId\": \"foo\"}"; | 23 const char* json = "{\"entryId\": \"foo\"}"; |
24 std::unique_ptr<base::Value> object = base::JSONReader::Read(json); | 24 std::unique_ptr<base::Value> object = base::JSONReader::Read(json); |
25 EXPECT_TRUE(object); | 25 EXPECT_TRUE(object); |
26 | 26 |
27 ErrorReporter errors; | 27 ErrorReporter errors; |
28 EXPECT_FALSE(accessibility::GetAXNodeParams::Parse(*object, &errors)); | 28 EXPECT_FALSE(page::NavigateToHistoryEntryParams::Parse(*object, &errors)); |
29 EXPECT_TRUE(errors.HasErrors()); | 29 EXPECT_TRUE(errors.HasErrors()); |
30 } | 30 } |
31 | 31 |
32 TEST(TypesTest, BooleanProperty) { | 32 TEST(TypesTest, BooleanProperty) { |
33 std::unique_ptr<memory::SetPressureNotificationsSuppressedParams> object( | 33 std::unique_ptr<memory::SetPressureNotificationsSuppressedParams> object( |
34 memory::SetPressureNotificationsSuppressedParams::Builder() | 34 memory::SetPressureNotificationsSuppressedParams::Builder() |
35 .SetSuppressed(true) | 35 .SetSuppressed(true) |
36 .Build()); | 36 .Build()); |
37 EXPECT_TRUE(object); | 37 EXPECT_TRUE(object); |
38 EXPECT_TRUE(object->GetSuppressed()); | 38 EXPECT_TRUE(object->GetSuppressed()); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 std::unique_ptr<accessibility::AXValue> clone(object->Clone()); | 191 std::unique_ptr<accessibility::AXValue> clone(object->Clone()); |
192 EXPECT_TRUE(clone); | 192 EXPECT_TRUE(clone); |
193 EXPECT_EQ(base::Value::TYPE_INTEGER, clone->GetValue()->GetType()); | 193 EXPECT_EQ(base::Value::TYPE_INTEGER, clone->GetValue()->GetType()); |
194 | 194 |
195 int clone_value; | 195 int clone_value; |
196 EXPECT_TRUE(clone->GetValue()->GetAsInteger(&clone_value)); | 196 EXPECT_TRUE(clone->GetValue()->GetAsInteger(&clone_value)); |
197 EXPECT_EQ(123, clone_value); | 197 EXPECT_EQ(123, clone_value); |
198 } | 198 } |
199 | 199 |
200 } // namespace headless | 200 } // namespace headless |
OLD | NEW |