OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #include <string> | |
6 #include <vector> | |
7 | |
8 #include "chrome/test/webdriver/frame_path.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace webdriver { | |
12 | |
13 TEST(FramePathTest, Constructors) { | |
14 EXPECT_EQ("", FramePath().value()); | |
15 EXPECT_EQ("frame", FramePath("frame").value()); | |
16 EXPECT_EQ("frame", FramePath(FramePath("frame")).value()); | |
17 } | |
18 | |
19 TEST(FramePathTest, Append) { | |
20 EXPECT_EQ("frame", FramePath().Append("frame").value()); | |
21 EXPECT_EQ("frame1\nframe2", FramePath("frame1").Append("frame2").value()); | |
22 } | |
23 | |
24 TEST(FramePathTest, Parent) { | |
25 FramePath path = FramePath("frame1").Append("frame2"); | |
26 EXPECT_EQ("frame1", path.Parent().value()); | |
27 EXPECT_EQ("", path.Parent().Parent().value()); | |
28 EXPECT_EQ("", path.Parent().Parent().Parent().value()); | |
29 } | |
30 | |
31 TEST(FramePathTest, BaseName) { | |
32 FramePath path = FramePath("frame1").Append("frame2"); | |
33 EXPECT_EQ("frame2", path.BaseName().value()); | |
34 EXPECT_EQ("frame1", path.Parent().BaseName().value()); | |
35 EXPECT_EQ("", path.Parent().Parent().BaseName().value()); | |
36 } | |
37 | |
38 TEST(FramePathTest, GetComponents) { | |
39 FramePath path = FramePath("frame1").Append("frame2"); | |
40 std::vector<std::string> components; | |
41 path.GetComponents(&components); | |
42 ASSERT_EQ(2u, components.size()); | |
43 EXPECT_EQ("frame1", components[0]); | |
44 EXPECT_EQ("frame2", components[1]); | |
45 | |
46 components.clear(); | |
47 path.Parent().GetComponents(&components); | |
48 ASSERT_EQ(1u, components.size()); | |
49 EXPECT_EQ("frame1", components[0]); | |
50 | |
51 components.clear(); | |
52 path.Parent().Parent().GetComponents(&components); | |
53 EXPECT_EQ(0u, components.size()); | |
54 } | |
55 | |
56 TEST(FramePathTest, IsRootFrame) { | |
57 EXPECT_TRUE(FramePath().IsRootFrame()); | |
58 EXPECT_FALSE(FramePath("frame").IsRootFrame()); | |
59 } | |
60 | |
61 TEST(FramePathTest, IsSubframe) { | |
62 EXPECT_FALSE(FramePath().IsSubframe()); | |
63 EXPECT_TRUE(FramePath("frame").IsSubframe()); | |
64 } | |
65 | |
66 } // namespace webdriver | |
OLD | NEW |