OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "printing/page_setup.h" | 5 #include "printing/page_setup.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 EXPECT_EQ(setup.effective_margins().top, 2); | 183 EXPECT_EQ(setup.effective_margins().top, 2); |
184 EXPECT_EQ(setup.effective_margins().right, 3); | 184 EXPECT_EQ(setup.effective_margins().right, 3); |
185 EXPECT_EQ(setup.effective_margins().bottom, 4); | 185 EXPECT_EQ(setup.effective_margins().bottom, 4); |
186 | 186 |
187 setup.ForceRequestedMargins(margins); | 187 setup.ForceRequestedMargins(margins); |
188 EXPECT_EQ(setup.effective_margins().left, 0); | 188 EXPECT_EQ(setup.effective_margins().left, 0); |
189 EXPECT_EQ(setup.effective_margins().top, 0); | 189 EXPECT_EQ(setup.effective_margins().top, 0); |
190 EXPECT_EQ(setup.effective_margins().right, 0); | 190 EXPECT_EQ(setup.effective_margins().right, 0); |
191 EXPECT_EQ(setup.effective_margins().bottom, 0); | 191 EXPECT_EQ(setup.effective_margins().bottom, 0); |
192 } | 192 } |
193 | |
194 TEST(PageSetupTest, FlipOrientation) { | |
195 // Margins. | |
196 printing::PageMargins margins; | |
197 margins.header = 2; | |
198 margins.footer = 2; | |
199 margins.left = 4; | |
200 margins.top = 14; | |
201 margins.right = 5; | |
202 margins.bottom = 7; | |
203 int kTextHeight = 3; | |
204 | |
205 // Page description. | |
206 gfx::Size page_size(100, 70); | |
207 gfx::Rect printable_area(3, 3, 92, 50); | |
208 | |
209 // Make the calculations. | |
210 printing::PageSetup setup; | |
211 setup.Init(page_size, printable_area, kTextHeight); | |
212 setup.SetRequestedMargins(margins); | |
213 | |
214 EXPECT_EQ(setup.effective_margins().left, 4); | |
215 EXPECT_EQ(setup.effective_margins().top, 14); | |
216 EXPECT_EQ(setup.effective_margins().right, 5); | |
217 EXPECT_EQ(setup.effective_margins().bottom, 20); | |
218 | |
219 setup.FlipOrientation(); | |
vandebo (ex-Chrome)
2011/11/02 20:26:03
Let's check all the values (physical_size_, printa
kmadhusu
2011/11/02 23:15:03
Done.
| |
220 EXPECT_EQ(setup.effective_margins().left, 14); | |
221 EXPECT_EQ(setup.effective_margins().top, 8); | |
222 EXPECT_EQ(setup.effective_margins().right, 17); | |
223 EXPECT_EQ(setup.effective_margins().bottom, 6); | |
224 | |
225 // Force requested margins and flip the orientation. | |
226 setup.Init(page_size, printable_area, kTextHeight); | |
227 setup.ForceRequestedMargins(margins); | |
228 EXPECT_EQ(setup.effective_margins().left, 4); | |
229 EXPECT_EQ(setup.effective_margins().top, 14); | |
230 EXPECT_EQ(setup.effective_margins().right, 5); | |
231 EXPECT_EQ(setup.effective_margins().bottom, 7); | |
232 | |
233 setup.FlipOrientation(); | |
234 // Margins values are changed respectively. | |
235 EXPECT_EQ(setup.effective_margins().left,14); | |
236 EXPECT_EQ(setup.effective_margins().top, 5); | |
237 EXPECT_EQ(setup.effective_margins().right, 7); | |
238 EXPECT_EQ(setup.effective_margins().bottom, 4); | |
239 } | |
OLD | NEW |