OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/ui/cocoa/applescript/apple_event_util.h" | 5 #import "chrome/browser/ui/cocoa/applescript/apple_event_util.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
12 #include "testing/gtest_mac.h" | 12 #include "testing/gtest_mac.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class AppleEventUtilTest : public CocoaTest { }; | 16 class AppleEventUtilTest : public CocoaTest { }; |
17 | 17 |
18 struct TestCase { | 18 struct TestCase { |
19 const char* json_input; | 19 const char* json_input; |
20 const char* expected_aedesc_dump; | 20 const char* expected_aedesc_dump; |
21 DescType expected_aedesc_type; | 21 DescType expected_aedesc_type; |
22 }; | 22 }; |
23 | 23 |
24 TEST_F(AppleEventUtilTest, DISABLED_ValueToAppleEventDescriptor) { | 24 TEST_F(AppleEventUtilTest, ValueToAppleEventDescriptor) { |
25 const struct TestCase cases[] = { | 25 const struct TestCase cases[] = { |
26 { "null", "'msng'", typeType }, | 26 { "null", "'msng'", typeType }, |
27 { "-1000", "-1000", typeSInt32 }, | 27 { "-1000", "-1000", typeSInt32 }, |
28 { "0", "0", typeSInt32 }, | 28 { "0", "0", typeSInt32 }, |
29 { "1000", "1000", typeSInt32 }, | 29 { "1000", "1000", typeSInt32 }, |
30 { "-1e100", "-1e+100", typeIEEE64BitFloatingPoint }, | 30 { "-1e100", "-1e+100", typeIEEE64BitFloatingPoint }, |
31 { "0.0", "0", typeIEEE64BitFloatingPoint }, | 31 { "0.0", "0", typeIEEE64BitFloatingPoint }, |
32 { "1e100", "1e+100", typeIEEE64BitFloatingPoint }, | 32 { "1e100", "1e+100", typeIEEE64BitFloatingPoint }, |
33 { "\"\"", "'utxt'(\"\")", typeUnicodeText }, | |
34 { "\"string\"", "'utxt'(\"string\")", typeUnicodeText }, | 33 { "\"string\"", "'utxt'(\"string\")", typeUnicodeText }, |
35 { "{}", "{ 'usrf':[ ] }", typeAERecord }, | 34 { "{}", "{ 'usrf':[ ] }", typeAERecord }, |
36 { "[]", "[ ]", typeAEList }, | 35 { "[]", "[ ]", typeAEList }, |
37 { "{\"Image\": {" | 36 { "{\"Image\": {" |
38 "\"Width\": 800," | 37 "\"Width\": 800," |
39 "\"Height\": 600," | 38 "\"Height\": 600," |
40 "\"Title\": \"View from 15th Floor\"," | 39 "\"Title\": \"View from 15th Floor\"," |
41 "\"Thumbnail\": {" | 40 "\"Thumbnail\": {" |
42 "\"Url\": \"http://www.example.com/image/481989943\"," | 41 "\"Url\": \"http://www.example.com/image/481989943\"," |
43 "\"Height\": 125," | 42 "\"Height\": 125," |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 base::FundamentalValue value(b); | 111 base::FundamentalValue value(b); |
113 NSAppleEventDescriptor* descriptor = | 112 NSAppleEventDescriptor* descriptor = |
114 chrome::mac::ValueToAppleEventDescriptor(&value); | 113 chrome::mac::ValueToAppleEventDescriptor(&value); |
115 | 114 |
116 EXPECT_EQ(typeBoolean, [descriptor descriptorType]); | 115 EXPECT_EQ(typeBoolean, [descriptor descriptorType]); |
117 EXPECT_EQ(b, [descriptor booleanValue]); | 116 EXPECT_EQ(b, [descriptor booleanValue]); |
118 } | 117 } |
119 } | 118 } |
120 | 119 |
121 } // namespace | 120 } // namespace |
OLD | NEW |