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

Side by Side Diff: ios/chrome/browser/ui/toolbar/web_toolbar_controller_unittest.mm

Issue 2830093003: Replace uses of hash_map in //base (Closed)
Patch Set: iOS Created 3 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/chrome/browser/ui/toolbar/web_toolbar_controller.h" 5 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include <map>
9 #include <memory> 10 #include <memory>
10 11
11 #include "base/ios/ios_util.h" 12 #include "base/ios/ios_util.h"
12 #include "base/mac/scoped_nsobject.h" 13 #include "base/mac/scoped_nsobject.h"
13 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 16 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
16 #import "ios/chrome/browser/ui/toolbar/test_toolbar_model_ios.h" 17 #import "ios/chrome/browser/ui/toolbar/test_toolbar_model_ios.h"
17 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller_private.h" 18 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller_private.h"
18 #include "ios/chrome/browser/ui/ui_util.h" 19 #include "ios/chrome/browser/ui/ui_util.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 toolbar_model_->set_text(base::UTF8ToUTF16(kExpectedUrlText)); 182 toolbar_model_->set_text(base::UTF8ToUTF16(kExpectedUrlText));
182 [web_toolbar_controller_ updateToolbarState]; 183 [web_toolbar_controller_ updateToolbarState];
183 std::string actualUrlText = [web_toolbar_controller_ getLocationText]; 184 std::string actualUrlText = [web_toolbar_controller_ getLocationText];
184 EXPECT_EQ(kExpectedUrlText, actualUrlText); 185 EXPECT_EQ(kExpectedUrlText, actualUrlText);
185 } 186 }
186 187
187 TEST_F(WebToolbarControllerTest, TestUpdateToolbar_TestLayoutOmnibox) { 188 TEST_F(WebToolbarControllerTest, TestUpdateToolbar_TestLayoutOmnibox) {
188 // Test that the initial setup of the toolbar matches the layout produced by 189 // Test that the initial setup of the toolbar matches the layout produced by
189 // calling layoutOmnibox. If the initial frames do not match those set during 190 // calling layoutOmnibox. If the initial frames do not match those set during
190 // layoutOmnibox, there will be minor animations during startup. 191 // layoutOmnibox, there will be minor animations during startup.
191 typedef base::hash_map<unsigned long, CGRect> FrameHash; 192 typedef std::map<unsigned long, CGRect> FrameHash;
192 typedef base::hash_map<unsigned long, CGRect>::iterator FrameHashIter; 193 typedef std::map<unsigned long, CGRect>::iterator FrameHashIter;
193 FrameHash initialFrames; 194 FrameHash initialFrames;
194 FrameHash postLayoutFrames; 195 FrameHash postLayoutFrames;
195 196
196 for (UIView* view in [[web_toolbar_controller_ view] allSubviews]) { 197 for (UIView* view in [[web_toolbar_controller_ view] allSubviews]) {
197 initialFrames.insert(std::make_pair<unsigned long, CGRect>( 198 initialFrames.insert(std::make_pair<unsigned long, CGRect>(
198 (unsigned long)view, [view frame])); 199 (unsigned long)view, [view frame]));
199 } 200 }
200 201
201 [web_toolbar_controller_ layoutOmnibox]; 202 [web_toolbar_controller_ layoutOmnibox];
202 203
203 for (UIView* view in [[web_toolbar_controller_ view] allSubviews]) { 204 for (UIView* view in [[web_toolbar_controller_ view] allSubviews]) {
204 postLayoutFrames.insert(std::make_pair<unsigned long, CGRect>( 205 postLayoutFrames.insert(std::make_pair<unsigned long, CGRect>(
205 (unsigned long)view, [view frame])); 206 (unsigned long)view, [view frame]));
206 } 207 }
207 208
208 FrameHashIter initialIt = initialFrames.begin(); 209 FrameHashIter initialIt = initialFrames.begin();
209 while (initialIt != initialFrames.end()) { 210 while (initialIt != initialFrames.end()) {
210 FrameHashIter postLayoutIt = postLayoutFrames.find(initialIt->first); 211 FrameHashIter postLayoutIt = postLayoutFrames.find(initialIt->first);
211 EXPECT_TRUE(postLayoutIt != postLayoutFrames.end()); 212 EXPECT_TRUE(postLayoutIt != postLayoutFrames.end());
212 CGRect initialRect = initialIt->second; 213 CGRect initialRect = initialIt->second;
213 CGRect layoutRect = postLayoutIt->second; 214 CGRect layoutRect = postLayoutIt->second;
214 EXPECT_EQ(initialRect.origin.x, layoutRect.origin.x); 215 EXPECT_EQ(initialRect.origin.x, layoutRect.origin.x);
215 EXPECT_EQ(initialRect.origin.y, layoutRect.origin.y); 216 EXPECT_EQ(initialRect.origin.y, layoutRect.origin.y);
216 EXPECT_EQ(initialRect.size.width, layoutRect.size.width); 217 EXPECT_EQ(initialRect.size.width, layoutRect.size.width);
217 EXPECT_EQ(initialRect.size.height, layoutRect.size.height); 218 EXPECT_EQ(initialRect.size.height, layoutRect.size.height);
218 initialIt++; 219 initialIt++;
219 } 220 }
220 } 221 }
221 } // namespace 222 } // namespace
OLDNEW
« no previous file with comments | « gpu/ipc/host/shader_disk_cache.h ('k') | third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698