• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2009 Google Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7#    * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9#    * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following disclaimer
11# in the documentation and/or other materials provided with the
12# distribution.
13#    * Neither the name of Google Inc. nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29import unittest
30import diff_parser
31
32
33class DiffParserTest(unittest.TestCase):
34
35    _PATCH = '''diff --git a/WebCore/rendering/style/StyleFlexibleBoxData.h b/WebCore/rendering/style/StyleFlexibleBoxData.h
36index f5d5e74..3b6aa92 100644
37--- a/WebCore/rendering/style/StyleFlexibleBoxData.h
38+++ b/WebCore/rendering/style/StyleFlexibleBoxData.h
39@@ -47,7 +47,6 @@ public:
40
41     unsigned align : 3; // EBoxAlignment
42     unsigned pack: 3; // EBoxAlignment
43-    unsigned orient: 1; // EBoxOrient
44     unsigned lines : 1; // EBoxLines
45
46 private:
47diff --git a/WebCore/rendering/style/StyleRareInheritedData.cpp b/WebCore/rendering/style/StyleRareInheritedData.cpp
48index ce21720..324929e 100644
49--- a/WebCore/rendering/style/StyleRareInheritedData.cpp
50+++ b/WebCore/rendering/style/StyleRareInheritedData.cpp
51@@ -39,6 +39,7 @@ StyleRareInheritedData::StyleRareInheritedData()
52     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
53     , resize(RenderStyle::initialResize())
54     , userSelect(RenderStyle::initialUserSelect())
55+    , boxOrient(RenderStyle::initialBoxOrient())
56 {
57 }
58
59@@ -58,6 +59,7 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
60     , textSizeAdjust(o.textSizeAdjust)
61     , resize(o.resize)
62     , userSelect(o.userSelect)
63+    , boxOrient(o.boxOrient)
64 {
65 }
66
67@@ -81,7 +83,8 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
68         && khtmlLineBreak == o.khtmlLineBreak
69         && textSizeAdjust == o.textSizeAdjust
70         && resize == o.resize
71-        && userSelect == o.userSelect;
72+        && userSelect == o.userSelect
73+        && boxOrient == o.boxOrient;
74 }
75
76 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
77diff --git a/LayoutTests/platform/mac/fast/flexbox/box-orient-button-expected.checksum b/LayoutTests/platform/mac/fast/flexbox/box-orient-button-expected.checksum
78new file mode 100644
79index 0000000..6db26bd
80--- /dev/null
81+++ b/LayoutTests/platform/mac/fast/flexbox/box-orient-button-expected.checksum
82@@ -0,0 +1 @@
83+61a373ee739673a9dcd7bac62b9f182e
84\ No newline at end of file
85'''.splitlines()
86
87
88    def test_diff_parser(self):
89        parser = diff_parser.DiffParser(self._PATCH)
90        self.assertEquals(3, len(parser.files))
91
92        self.assertTrue('WebCore/rendering/style/StyleFlexibleBoxData.h' in parser.files)
93        diff = parser.files['WebCore/rendering/style/StyleFlexibleBoxData.h']
94        self.assertEquals(7, len(diff.lines))
95        # The first two unchaged lines.
96        self.assertEquals((47, 47), diff.lines[0][0:2])
97        self.assertEquals('', diff.lines[0][2])
98        self.assertEquals((48, 48), diff.lines[1][0:2])
99        self.assertEquals('    unsigned align : 3; // EBoxAlignment', diff.lines[1][2])
100        # The deleted line
101        self.assertEquals((50, 0), diff.lines[3][0:2])
102        self.assertEquals('    unsigned orient: 1; // EBoxOrient', diff.lines[3][2])
103
104        # The first file looks OK. Let's check the next, more complicated file.
105        self.assertTrue('WebCore/rendering/style/StyleRareInheritedData.cpp' in parser.files)
106        diff = parser.files['WebCore/rendering/style/StyleRareInheritedData.cpp']
107        # There are 3 chunks.
108        self.assertEquals(7 + 7 + 9, len(diff.lines))
109        # Around an added line.
110        self.assertEquals((60, 61), diff.lines[9][0:2])
111        self.assertEquals((0, 62), diff.lines[10][0:2])
112        self.assertEquals((61, 63), diff.lines[11][0:2])
113        # Look through the last chunk, which contains both add's and delete's.
114        self.assertEquals((81, 83), diff.lines[14][0:2])
115        self.assertEquals((82, 84), diff.lines[15][0:2])
116        self.assertEquals((83, 85), diff.lines[16][0:2])
117        self.assertEquals((84, 0), diff.lines[17][0:2])
118        self.assertEquals((0, 86), diff.lines[18][0:2])
119        self.assertEquals((0, 87), diff.lines[19][0:2])
120        self.assertEquals((85, 88), diff.lines[20][0:2])
121        self.assertEquals((86, 89), diff.lines[21][0:2])
122        self.assertEquals((87, 90), diff.lines[22][0:2])
123
124        # Check if a newly added file is correctly handled.
125        diff = parser.files['LayoutTests/platform/mac/fast/flexbox/box-orient-button-expected.checksum']
126        self.assertEquals(1, len(diff.lines))
127        self.assertEquals((0, 1), diff.lines[0][0:2])
128
129
130if __name__ == '__main__':
131    unittest.main()
132