Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: ash/display/json_converter_unittest.cc

Issue 1819533002: Convert ScopedVector<DisplayPlacement> to std::vector<DisplayPlacement> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@jsonrefactor
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/display/json_converter.cc ('k') | ash/display/mouse_cursor_event_filter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/display/json_converter.h" 5 #include "ash/display/json_converter.h"
6 6
7 #include "ash/display/display_layout.h" 7 #include "ash/display/display_layout.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace ash { 12 namespace ash {
13 13
14 TEST(JsonConverterTest, JsonFromToDisplayLayout) { 14 TEST(JsonConverterTest, JsonFromToDisplayLayout) {
15 DisplayLayout layout; 15 DisplayLayout layout;
16 layout.primary_id = 1; 16 layout.primary_id = 1;
17 layout.mirrored = true; 17 layout.mirrored = true;
18 layout.default_unified = false; 18 layout.default_unified = false;
19 layout.placement_list.push_back(new DisplayPlacement); 19 layout.placement_list.push_back(DisplayPlacement());
20 layout.placement_list.push_back(new DisplayPlacement); 20 layout.placement_list.push_back(DisplayPlacement());
21 layout.placement_list[0]->display_id = 2; 21 layout.placement_list[0].display_id = 2;
22 layout.placement_list[0]->parent_display_id = 1; 22 layout.placement_list[0].parent_display_id = 1;
23 layout.placement_list[0]->position = DisplayPlacement::BOTTOM; 23 layout.placement_list[0].position = DisplayPlacement::BOTTOM;
24 24
25 layout.placement_list[1]->display_id = 3; 25 layout.placement_list[1].display_id = 3;
26 layout.placement_list[1]->parent_display_id = 2; 26 layout.placement_list[1].parent_display_id = 2;
27 layout.placement_list[1]->position = DisplayPlacement::LEFT; 27 layout.placement_list[1].position = DisplayPlacement::LEFT;
28 layout.placement_list[1]->offset = 30; 28 layout.placement_list[1].offset = 30;
29 29
30 base::DictionaryValue value; 30 base::DictionaryValue value;
31 DisplayLayoutToJson(layout, &value); 31 DisplayLayoutToJson(layout, &value);
32 32
33 const char data[] = 33 const char data[] =
34 "{\n" 34 "{\n"
35 " \"primary-id\": \"1\",\n" 35 " \"primary-id\": \"1\",\n"
36 " \"mirrored\": true,\n" 36 " \"mirrored\": true,\n"
37 " \"default_unified\": false,\n" 37 " \"default_unified\": false,\n"
38 " \"display_placement\": [{\n" 38 " \"display_placement\": [{\n"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 data, 0, &error_code, &error_msg, &error_line, &error_column)); 78 data, 0, &error_code, &error_msg, &error_line, &error_column));
79 ASSERT_EQ(0, error_code) << error_msg << " at " << error_line << ":" 79 ASSERT_EQ(0, error_code) << error_msg << " at " << error_line << ":"
80 << error_column; 80 << error_column;
81 81
82 DisplayLayout read_layout; 82 DisplayLayout read_layout;
83 EXPECT_TRUE(JsonToDisplayLayout(*read_value, &read_layout)); 83 EXPECT_TRUE(JsonToDisplayLayout(*read_value, &read_layout));
84 EXPECT_EQ(true, read_layout.mirrored); 84 EXPECT_EQ(true, read_layout.mirrored);
85 EXPECT_EQ(1, read_layout.primary_id); 85 EXPECT_EQ(1, read_layout.primary_id);
86 EXPECT_EQ(false, read_layout.default_unified); 86 EXPECT_EQ(false, read_layout.default_unified);
87 ASSERT_EQ(1u, read_layout.placement_list.size()); 87 ASSERT_EQ(1u, read_layout.placement_list.size());
88 EXPECT_EQ(DisplayPlacement::BOTTOM, read_layout.placement_list[0]->position); 88 EXPECT_EQ(DisplayPlacement::BOTTOM, read_layout.placement_list[0].position);
89 EXPECT_EQ(20, read_layout.placement_list[0]->offset); 89 EXPECT_EQ(20, read_layout.placement_list[0].offset);
90 } 90 }
91 91
92 } // namespace ash 92 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/json_converter.cc ('k') | ash/display/mouse_cursor_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698