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

Side by Side Diff: chrome/installer/util/install_util_unittest.cc

Issue 10446095: Move ProgramCompare from setup_util to install_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move tests Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/string_util.h"
9 #include "base/test/test_reg_util_win.h" 10 #include "base/test/test_reg_util_win.h"
10 #include "base/win/registry.h" 11 #include "base/win/registry.h"
11 #include "chrome/installer/util/google_update_constants.h" 12 #include "chrome/installer/util/google_update_constants.h"
12 #include "chrome/installer/util/install_util.h" 13 #include "chrome/installer/util/install_util.h"
13 #include "chrome/installer/util/product_unittest.h" 14 #include "chrome/installer/util/product_unittest.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 16
16 using base::win::RegKey; 17 using base::win::RegKey;
17 using registry_util::RegistryOverrideManager; 18 using registry_util::RegistryOverrideManager;
18 using ::testing::_; 19 using ::testing::_;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 350
350 TEST_F(InstallUtilTest, ValueEquals) { 351 TEST_F(InstallUtilTest, ValueEquals) {
351 InstallUtil::ValueEquals pred(L"howdy"); 352 InstallUtil::ValueEquals pred(L"howdy");
352 353
353 EXPECT_FALSE(pred.Evaluate(L"")); 354 EXPECT_FALSE(pred.Evaluate(L""));
354 EXPECT_FALSE(pred.Evaluate(L"Howdy")); 355 EXPECT_FALSE(pred.Evaluate(L"Howdy"));
355 EXPECT_FALSE(pred.Evaluate(L"howdy!")); 356 EXPECT_FALSE(pred.Evaluate(L"howdy!"));
356 EXPECT_FALSE(pred.Evaluate(L"!howdy")); 357 EXPECT_FALSE(pred.Evaluate(L"!howdy"));
357 EXPECT_TRUE(pred.Evaluate(L"howdy")); 358 EXPECT_TRUE(pred.Evaluate(L"howdy"));
358 } 359 }
360
361 TEST_F(InstallUtilTest, ProgramCompare) {
362 FilePath some_long_dir(test_dir_.path().Append(L"Some Long Directory Name"));
363 FilePath expect(some_long_dir.Append(L"file.txt"));
364 FilePath expect_upcase(some_long_dir.Append(L"FILE.txt"));
365 FilePath other(some_long_dir.Append(L"otherfile.txt"));
366
367 // Tests where the expected file doesn't exist.
368
369 // Paths don't match.
370 EXPECT_FALSE(InstallUtil::ProgramCompare(expect).Evaluate(
371 L"\"" + other.value() + L"\""));
372 // Paths match exactly.
373 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate(
374 L"\"" + expect.value() + L"\""));
375 // Paths differ by case.
376 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate(
377 L"\"" + expect_upcase.value() + L"\""));
378
379 // Tests where the expected file exists.
380 static const char data[] = "data";
381 ASSERT_TRUE(file_util::CreateDirectory(some_long_dir));
382 ASSERT_NE(-1, file_util::WriteFile(expect, data, arraysize(data) - 1));
383 // Paths don't match.
384 EXPECT_FALSE(InstallUtil::ProgramCompare(expect).Evaluate(
385 L"\"" + other.value() + L"\""));
386 // Paths match exactly.
387 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate(
388 L"\"" + expect.value() + L"\""));
389 // Paths differ by case.
390 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate(
391 L"\"" + expect_upcase.value() + L"\""));
392
393 // Test where strings don't match, but the same file is indicated.
394 std::wstring short_expect;
395 DWORD short_len = GetShortPathName(expect.value().c_str(),
396 WriteInto(&short_expect, MAX_PATH),
397 MAX_PATH);
398 ASSERT_NE(static_cast<DWORD>(0), short_len);
399 ASSERT_GT(static_cast<DWORD>(MAX_PATH), short_len);
400 short_expect.resize(short_len);
401 ASSERT_FALSE(FilePath::CompareEqualIgnoreCase(expect.value(), short_expect));
402 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate(
403 L"\"" + short_expect + L"\""));
404 }
gab 2012/05/31 16:32:05 Ends by 0A 7D 0A so rietveld's lint is lying.
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698