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

Side by Side Diff: ui/base/win/open_file_name_win_unittest.cc

Issue 2126433002: Use container::back() and container::pop_back() in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pre-increment Created 4 years, 5 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 | « ui/base/ime/win/imm32_manager.cc ('k') | ui/compositor/layer_animator_collection.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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "ui/base/win/open_file_name_win.h" 5 #include "ui/base/win/open_file_name_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace { 13 namespace {
14 const HWND kHwnd = reinterpret_cast<HWND>(0xDEADBEEF); 14 const HWND kHwnd = reinterpret_cast<HWND>(0xDEADBEEF);
15 const DWORD kFlags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING; 15 const DWORD kFlags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING;
16 16
17 void SetResult(const base::string16& result, ui::win::OpenFileName* ofn) { 17 void SetResult(const base::string16& result, ui::win::OpenFileName* ofn) {
18 if (ofn->GetOPENFILENAME()->nMaxFile <= result.size()) { 18 if (ofn->GetOPENFILENAME()->nMaxFile <= result.size()) {
19 ADD_FAILURE() << "filename buffer insufficient."; 19 ADD_FAILURE() << "filename buffer insufficient.";
20 return; 20 return;
21 } 21 }
22 if (!result.size()) { 22 if (result.empty()) {
23 ofn->GetOPENFILENAME()->lpstrFile[0] = 0; 23 ofn->GetOPENFILENAME()->lpstrFile[0] = 0;
24 } else { 24 } else {
25 // Because the result has embedded nulls, we must memcpy. 25 // Because the result has embedded nulls, we must memcpy.
26 memcpy(ofn->GetOPENFILENAME()->lpstrFile, 26 memcpy(ofn->GetOPENFILENAME()->lpstrFile,
27 result.c_str(), 27 result.c_str(),
28 (result.size() + 1) * sizeof(result[0])); 28 (result.size() + 1) * sizeof(result[0]));
29 } 29 }
30 } 30 }
31 31
32 void CheckFilters( 32 void CheckFilters(
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME()); 247 ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME());
248 CheckResult(L"C:\\dir" + kNull + L"file" + kNull + L"otherfile" + kNull, ofn); 248 CheckResult(L"C:\\dir" + kNull + L"file" + kNull + L"otherfile" + kNull, ofn);
249 249
250 base::char16 short_buffer[10] = L""; 250 base::char16 short_buffer[10] = L"";
251 251
252 ofn.GetOPENFILENAME()->lpstrFile = short_buffer; 252 ofn.GetOPENFILENAME()->lpstrFile = short_buffer;
253 ofn.GetOPENFILENAME()->nMaxFile = arraysize(short_buffer); 253 ofn.GetOPENFILENAME()->nMaxFile = arraysize(short_buffer);
254 ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME()); 254 ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME());
255 CheckResult(L"", ofn); 255 CheckResult(L"", ofn);
256 } 256 }
OLDNEW
« no previous file with comments | « ui/base/ime/win/imm32_manager.cc ('k') | ui/compositor/layer_animator_collection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698