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
|
// 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 <string>
#include <vector>
#include "chrome/test/webdriver/frame_path.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace webdriver {
TEST(FramePathTest, Constructors) {
EXPECT_EQ("", FramePath().value());
EXPECT_EQ("frame", FramePath("frame").value());
EXPECT_EQ("frame", FramePath(FramePath("frame")).value());
}
TEST(FramePathTest, Append) {
EXPECT_EQ("frame", FramePath().Append("frame").value());
EXPECT_EQ("frame1\nframe2", FramePath("frame1").Append("frame2").value());
}
TEST(FramePathTest, Parent) {
FramePath path = FramePath("frame1").Append("frame2");
EXPECT_EQ("frame1", path.Parent().value());
EXPECT_EQ("", path.Parent().Parent().value());
EXPECT_EQ("", path.Parent().Parent().Parent().value());
}
TEST(FramePathTest, BaseName) {
FramePath path = FramePath("frame1").Append("frame2");
EXPECT_EQ("frame2", path.BaseName().value());
EXPECT_EQ("frame1", path.Parent().BaseName().value());
EXPECT_EQ("", path.Parent().Parent().BaseName().value());
}
TEST(FramePathTest, GetComponents) {
FramePath path = FramePath("frame1").Append("frame2");
std::vector<std::string> components;
path.GetComponents(&components);
ASSERT_EQ(2u, components.size());
EXPECT_EQ("frame1", components[0]);
EXPECT_EQ("frame2", components[1]);
components.clear();
path.Parent().GetComponents(&components);
ASSERT_EQ(1u, components.size());
EXPECT_EQ("frame1", components[0]);
components.clear();
path.Parent().Parent().GetComponents(&components);
EXPECT_EQ(0u, components.size());
}
TEST(FramePathTest, IsRootFrame) {
EXPECT_TRUE(FramePath().IsRootFrame());
EXPECT_FALSE(FramePath("frame").IsRootFrame());
}
TEST(FramePathTest, IsSubframe) {
EXPECT_FALSE(FramePath().IsSubframe());
EXPECT_TRUE(FramePath("frame").IsSubframe());
}
} // namespace webdriver
|