Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/web/public/web_state/page_display_state.h" | 5 #import "ios/web/public/web_state/page_display_state.h" |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 8 |
| 10 #define EXPECT_NAN(value) EXPECT_NE(value, value) | 9 #define EXPECT_NAN(value) EXPECT_NE(value, value) |
| 11 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 12 #error "This file requires ARC support." | |
| 13 #endif | |
| 14 | |
| 12 // Tests that the empty constructor creates an invalid PageDisplayState with all | 15 // Tests that the empty constructor creates an invalid PageDisplayState with all |
| 13 // NAN values. | 16 // NAN values. |
| 14 TEST(PageDisplayStateTest, EmptyConstructor) { | 17 TEST(PageDisplayStateTest, EmptyConstructor) { |
| 15 web::PageDisplayState state; | 18 web::PageDisplayState state; |
| 16 EXPECT_NAN(state.scroll_state().offset_x()); | 19 EXPECT_NAN(state.scroll_state().offset_x()); |
| 17 EXPECT_NAN(state.scroll_state().offset_y()); | 20 EXPECT_NAN(state.scroll_state().offset_y()); |
| 18 EXPECT_NAN(state.zoom_state().minimum_zoom_scale()); | 21 EXPECT_NAN(state.zoom_state().minimum_zoom_scale()); |
| 19 EXPECT_NAN(state.zoom_state().maximum_zoom_scale()); | 22 EXPECT_NAN(state.zoom_state().maximum_zoom_scale()); |
| 20 EXPECT_NAN(state.zoom_state().zoom_scale()); | 23 EXPECT_NAN(state.zoom_state().zoom_scale()); |
| 21 EXPECT_FALSE(state.IsValid()); | 24 EXPECT_FALSE(state.IsValid()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 51 EXPECT_EQ(1.0, state.scroll_state().offset_y()); | 54 EXPECT_EQ(1.0, state.scroll_state().offset_y()); |
| 52 EXPECT_EQ(1.0, state.zoom_state().minimum_zoom_scale()); | 55 EXPECT_EQ(1.0, state.zoom_state().minimum_zoom_scale()); |
| 53 EXPECT_EQ(5.0, state.zoom_state().maximum_zoom_scale()); | 56 EXPECT_EQ(5.0, state.zoom_state().maximum_zoom_scale()); |
| 54 EXPECT_EQ(1.0, state.zoom_state().zoom_scale()); | 57 EXPECT_EQ(1.0, state.zoom_state().zoom_scale()); |
| 55 EXPECT_TRUE(state.IsValid()); | 58 EXPECT_TRUE(state.IsValid()); |
| 56 } | 59 } |
| 57 | 60 |
| 58 // Tests converting between a PageDisplayState, its serialization, and back. | 61 // Tests converting between a PageDisplayState, its serialization, and back. |
| 59 TEST(PageDisplayStateTest, Serialization) { | 62 TEST(PageDisplayStateTest, Serialization) { |
| 60 web::PageDisplayState state(0.0, 1.0, 1.0, 5.0, 1.0); | 63 web::PageDisplayState state(0.0, 1.0, 1.0, 5.0, 1.0); |
| 61 base::scoped_nsobject<NSDictionary> serialization( | 64 NSDictionary* serialization = state.GetSerialization(); |
|
Eugene But (OOO till 7-30)
2017/06/14 13:34:02
Optional nit: consider dropping |serialization| lo
marq (ping after 24h)
2017/06/14 14:18:23
Done.
| |
| 62 [state.GetSerialization() retain]); | |
| 63 web::PageDisplayState new_state(serialization); | 65 web::PageDisplayState new_state(serialization); |
| 64 EXPECT_EQ(state, new_state); | 66 EXPECT_EQ(state, new_state); |
| 65 } | 67 } |
| OLD | NEW |