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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (c) 2006-2008 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 <map>
#include "webkit/tools/test_shell/layout_test_controller.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
// A subclass of LayoutTestController, with additional accessors.
class TestLayoutTestController : public LayoutTestController {
public:
TestLayoutTestController() : LayoutTestController(NULL) {
}
size_t MethodCount() {
return methods_.size();
}
void Reset() {
LayoutTestController::Reset();
}
};
class LayoutTestControllerTest : public testing::Test {
};
} // namespace
TEST(LayoutTestControllerTest, MethodMapIsInitialized) {
const char* test_methods[] = {
"dumpAsText",
"waitUntilDone",
"notifyDone",
"dumpEditingCallbacks",
"queueLoad",
"windowCount",
NULL
};
TestLayoutTestController controller;
for (const char** method = test_methods; *method; ++method) {
EXPECT_TRUE(controller.IsMethodRegistered(*method));
}
// One more case, to test our test.
EXPECT_FALSE(controller.IsMethodRegistered("nonexistent_method"));
}
TEST(LayoutTestControllerTest, DumpAsTextSetAndCleared) {
TestLayoutTestController controller;
CppArgumentList empty_args;
CppVariant ignored_result;
EXPECT_FALSE(controller.ShouldDumpAsText());
controller.dumpAsText(empty_args, &ignored_result);
EXPECT_TRUE(ignored_result.isNull());
EXPECT_TRUE(controller.ShouldDumpAsText());
// Don't worry about closing remaining windows when we call reset.
CppArgumentList args;
CppVariant bool_false;
bool_false.Set(false);
args.push_back(bool_false);
CppVariant result;
controller.setCloseRemainingWindowsWhenComplete(args, &result);
controller.Reset();
EXPECT_FALSE(controller.ShouldDumpAsText());
}
TEST(LayoutTestControllerTest, DumpChildFramesAsTextSetAndCleared) {
TestLayoutTestController controller;
CppArgumentList empty_args;
CppVariant ignored_result;
EXPECT_FALSE(controller.ShouldDumpChildFramesAsText());
controller.dumpChildFramesAsText(empty_args, &ignored_result);
EXPECT_TRUE(ignored_result.isNull());
EXPECT_TRUE(controller.ShouldDumpChildFramesAsText());
// Don't worry about closing remaining windows when we call reset.
CppArgumentList args;
CppVariant bool_false;
bool_false.Set(false);
args.push_back(bool_false);
CppVariant result;
controller.setCloseRemainingWindowsWhenComplete(args, &result);
controller.Reset();
EXPECT_FALSE(controller.ShouldDumpChildFramesAsText());
}
|