 Chromium Code Reviews
 Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <atlbase.h> | 5 #include <atlbase.h> | 
| 6 #include <atlcom.h> | 6 #include <atlcom.h> | 
| 7 | 7 | 
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" | 
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" | 
| 10 #include "base/scoped_comptr_win.h" | 10 #include "base/scoped_comptr_win.h" | 
| 11 #include "chrome_frame/urlmon_bind_status_callback.h" | 11 #include "chrome_frame/urlmon_bind_status_callback.h" | 
| 12 #include "chrome_frame/test/chrome_frame_test_utils.h" | |
| 12 #include "chrome_frame/test/urlmon_moniker_tests.h" | 13 #include "chrome_frame/test/urlmon_moniker_tests.h" | 
| 13 | 14 | 
| 15 using chrome_frame_test::ScopedVirtualizeHklmAndHkcu; | |
| 14 using testing::Return; | 16 using testing::Return; | 
| 15 using testing::Eq; | 17 using testing::Eq; | 
| 16 | 18 | 
| 17 class MonikerPatchTest : public testing::Test { | 19 class MonikerPatchTest : public testing::Test { | 
| 18 protected: | 20 protected: | 
| 19 MonikerPatchTest() { | 21 MonikerPatchTest() { | 
| 20 } | 22 } | 
| 21 | 23 | 
| 22 virtual void SetUp() { | 24 virtual void SetUp() { | 
| 25 DeleteAllSingletons(); | |
| 
amit
2010/12/08 23:40:35
It safe now to delete the moniker patch code along
 | |
| 23 PathService::Get(base::DIR_SOURCE_ROOT, &test_file_path_); | 26 PathService::Get(base::DIR_SOURCE_ROOT, &test_file_path_); | 
| 24 test_file_path_ = test_file_path_.Append(FILE_PATH_LITERAL("chrome_frame")) | 27 test_file_path_ = test_file_path_.Append(FILE_PATH_LITERAL("chrome_frame")) | 
| 25 .Append(FILE_PATH_LITERAL("test")) | 28 .Append(FILE_PATH_LITERAL("test")) | 
| 26 .Append(FILE_PATH_LITERAL("data")); | 29 .Append(FILE_PATH_LITERAL("data")); | 
| 27 } | 30 } | 
| 28 | 31 | 
| 29 bool ReadFileAsString(const wchar_t* file_name, std::string* file_contents) { | 32 bool ReadFileAsString(const wchar_t* file_name, std::string* file_contents) { | 
| 30 EXPECT_TRUE(file_name); | 33 EXPECT_TRUE(file_name); | 
| 31 FilePath file_path = test_file_path_.Append(file_name); | 34 FilePath file_path = test_file_path_.Append(file_name); | 
| 32 return file_util::ReadFileToString(file_path, file_contents); | 35 return file_util::ReadFileToString(file_path, file_contents); | 
| (...skipping 18 matching lines...) Expand all Loading... | |
| 51 if (SUCCEEDED(hr)) { | 54 if (SUCCEEDED(hr)) { | 
| 52 RewindStream(stream); | 55 RewindStream(stream); | 
| 53 *ret = stream.Detach(); | 56 *ret = stream.Detach(); | 
| 54 result = true; | 57 result = true; | 
| 55 } | 58 } | 
| 56 | 59 | 
| 57 return result; | 60 return result; | 
| 58 } | 61 } | 
| 59 | 62 | 
| 60 FilePath test_file_path_; | 63 FilePath test_file_path_; | 
| 64 ScopedVirtualizeHklmAndHkcu virtualized_registry_; | |
| 61 }; | 65 }; | 
| 62 | 66 | 
| 63 // Tests the CacheStream class by writing content into a stream object | 67 // Tests the CacheStream class by writing content into a stream object | 
| 64 // and verify that reading that stream back | 68 // and verify that reading that stream back | 
| 65 TEST_F(MonikerPatchTest, CacheStream) { | 69 TEST_F(MonikerPatchTest, CacheStream) { | 
| 66 const char data[] = "ReadStreamCacheTest"; | 70 const char data[] = "ReadStreamCacheTest"; | 
| 67 char ret[2 * sizeof(data)] = {0}; | 71 char ret[2 * sizeof(data)] = {0}; | 
| 68 DWORD read = 0; | 72 DWORD read = 0; | 
| 69 | 73 | 
| 70 // Test 1: empty stream reads nothing | 74 // Test 1: empty stream reads nothing | 
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 | 244 | 
| 241 std::string data_read; | 245 std::string data_read; | 
| 242 data_read.append(read_buffer1.get(), read_size1); | 246 data_read.append(read_buffer1.get(), read_size1); | 
| 243 data_read.append(read_buffer2.get(), read_size2); | 247 data_read.append(read_buffer2.get(), read_size2); | 
| 244 EXPECT_EQ(small_html_meta_tag, data_read); | 248 EXPECT_EQ(small_html_meta_tag, data_read); | 
| 245 | 249 | 
| 246 EXPECT_EQ(S_FALSE, ret3); | 250 EXPECT_EQ(S_FALSE, ret3); | 
| 247 EXPECT_STREQ("", read_buffer3); | 251 EXPECT_STREQ("", read_buffer3); | 
| 248 EXPECT_EQ(sizeof(read_buffer3), read_size3); | 252 EXPECT_EQ(sizeof(read_buffer3), read_size3); | 
| 249 } | 253 } | 
| OLD | NEW |