OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/installer/mac/app/OmahaXMLRequest.h" | 5 #import "chrome/installer/mac/app/OmahaXMLRequest.h" |
6 | 6 |
| 7 #include "base/base_paths.h" |
| 8 #include "base/files/file_path.h" |
7 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/path_service.h" |
| 12 #include "base/strings/sys_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
10 | 14 |
11 namespace { | 15 namespace { |
12 | 16 |
13 TEST(OmahaXMLRequestTest, CreateReturnsValidXML) { | 17 TEST(OmahaXMLRequestTest, CreateReturnsValidXML) { |
14 base::scoped_nsobject<NSXMLDocument> xml_body_( | 18 NSXMLDocument* xml_body_ = [OmahaXMLRequest createXMLRequestBody]; |
15 [OmahaXMLRequest createXMLRequestBody]); | |
16 ASSERT_TRUE(xml_body_); | 19 ASSERT_TRUE(xml_body_); |
17 | 20 |
18 NSString* requestDTDLocation = [[[[NSBundle mainBundle] bundlePath] | 21 base::FilePath path; |
19 stringByAppendingPathComponent: | 22 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
20 @"../../chrome/installer/mac/app/testing/requestCheck.dtd"] | 23 path = path.AppendASCII("chrome/test/data/mac_installer/requestCheck.dtd"); |
21 stringByResolvingSymlinksInPath]; | 24 NSString* requestDTDLocation = base::SysUTF8ToNSString(path.value()); |
22 NSData* requestDTDData = [NSData dataWithContentsOfFile:requestDTDLocation]; | 25 NSData* requestDTDData = [NSData dataWithContentsOfFile:requestDTDLocation]; |
23 ASSERT_TRUE(requestDTDData); | 26 ASSERT_TRUE(requestDTDData); |
24 | 27 |
25 NSError* error; | 28 NSError* error; |
26 NSXMLDTD* requestXMLChecker = | 29 NSXMLDTD* requestXMLChecker = |
27 [[NSXMLDTD alloc] initWithData:requestDTDData options:0 error:&error]; | 30 [[NSXMLDTD alloc] initWithData:requestDTDData options:0 error:&error]; |
28 [requestXMLChecker setName:@"request"]; | 31 [requestXMLChecker setName:@"request"]; |
29 [xml_body_ setDTD:requestXMLChecker]; | 32 [xml_body_ setDTD:requestXMLChecker]; |
30 EXPECT_TRUE([xml_body_ validateAndReturnError:&error]); | 33 EXPECT_TRUE([xml_body_ validateAndReturnError:&error]); |
31 } | 34 } |
32 | 35 |
33 } // namespace | 36 } // namespace |
OLD | NEW |