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

Unified Diff: courgette/image_info_unittest.cc

Issue 8166013: Further refactoring, move ImageInfo into Disassembler/DisassemblerWin32X86. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase over other changes, fix nit. Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/image_info.cc ('k') | courgette/types_win_pe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/image_info_unittest.cc
diff --git a/courgette/image_info_unittest.cc b/courgette/image_info_unittest.cc
deleted file mode 100644
index e0cac7d81fdd95cb1dc64e6b6298381672f54969..0000000000000000000000000000000000000000
--- a/courgette/image_info_unittest.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "courgette/base_test_unittest.h"
-#include "courgette/image_info.h"
-
-class ImageInfoTest : public BaseTest {
- public:
-
- void TestExe() const;
- void TestResourceDll() const;
-
- private:
- void ExpectExecutable(courgette::PEInfo* info) const;
-
-};
-
-void ImageInfoTest::ExpectExecutable(courgette::PEInfo* info) const {
- EXPECT_TRUE(info->ok());
- EXPECT_TRUE(info->has_text_section());
-}
-
-void ImageInfoTest::TestExe() const {
- std::string file1 = FileContents("setup1.exe");
-
- scoped_ptr<courgette::PEInfo> info(new courgette::PEInfo());
- info->Init(reinterpret_cast<const uint8*>(file1.c_str()), file1.length());
-
- bool can_parse_header = info->ParseHeader();
- EXPECT_TRUE(can_parse_header);
-
- // The executable is the whole file, not 'embedded' with the file
- EXPECT_EQ(file1.length(), info->length());
-
- ExpectExecutable(info.get());
- EXPECT_EQ(449536U, info->size_of_code());
- EXPECT_EQ(SectionName(info->RVAToSection(0x00401234 - 0x00400000)),
- std::string(".text"));
-
- EXPECT_EQ(0, info->RVAToFileOffset(0));
- EXPECT_EQ(1024, info->RVAToFileOffset(4096));
- EXPECT_EQ(46928, info->RVAToFileOffset(50000));
-
- std::vector<courgette::RVA> relocs;
- bool can_parse_relocs = info->ParseRelocs(&relocs);
- EXPECT_TRUE(can_parse_relocs);
-
- const uint8* p = info->RVAToPointer(0);
- EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()),
- reinterpret_cast<const void*>(p));
- EXPECT_EQ('M', p[0]);
- EXPECT_EQ('Z', p[1]);
-}
-
-void ImageInfoTest::TestResourceDll() const {
- std::string file1 = FileContents("en-US.dll");
-
- scoped_ptr<courgette::PEInfo> info(new courgette::PEInfo());
- info->Init(reinterpret_cast<const uint8*>(file1.c_str()), file1.length());
-
- // This is expected to fail, since we don't really support them yet.
- bool can_parse_header = info->ParseHeader();
- EXPECT_FALSE(can_parse_header);
-
- // The executable is the whole file, not 'embedded' with the file
- EXPECT_EQ(file1.length(), info->length());
-
- EXPECT_FALSE(info->ok());
- EXPECT_FALSE(info->has_text_section());
- EXPECT_EQ(0U, info->size_of_code());
-}
-
-TEST_F(ImageInfoTest, All) {
- TestExe();
- TestResourceDll();
-}
« no previous file with comments | « courgette/image_info.cc ('k') | courgette/types_win_pe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698