| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest
.h" | 9 #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.h" |
| 10 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h" | 10 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h" |
| 11 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h" | 11 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #import "testing/gtest_mac.h" | 13 #import "testing/gtest_mac.h" |
| 14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 typedef BookmarkAppleScriptTest BookmarkItemAppleScriptTest; | 17 typedef BookmarkAppleScriptTest BookmarkItemAppleScriptTest; |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Set and get title. | 21 // Set and get title. |
| 22 TEST_F(BookmarkItemAppleScriptTest, GetAndSetTitle) { | 22 IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest, GetAndSetTitle) { |
| 23 NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems]; | 23 NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems]; |
| 24 BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0]; | 24 BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0]; |
| 25 [item1 setTitle:@"Foo"]; | 25 [item1 setTitle:@"Foo"]; |
| 26 EXPECT_NSEQ(@"Foo", [item1 title]); | 26 EXPECT_NSEQ(@"Foo", [item1 title]); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Set and get URL. | 29 // Set and get URL. |
| 30 TEST_F(BookmarkItemAppleScriptTest, GetAndSetURL) { | 30 IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest, GetAndSetURL) { |
| 31 NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems]; | 31 NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems]; |
| 32 BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0]; | 32 BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0]; |
| 33 [item1 setURL:@"http://foo-bar.org"]; | 33 [item1 setURL:@"http://foo-bar.org"]; |
| 34 EXPECT_EQ(GURL("http://foo-bar.org"), | 34 EXPECT_EQ(GURL("http://foo-bar.org"), |
| 35 GURL(base::SysNSStringToUTF8([item1 URL]))); | 35 GURL(base::SysNSStringToUTF8([item1 URL]))); |
| 36 | 36 |
| 37 // If scripter enters invalid URL. | 37 // If scripter enters invalid URL. |
| 38 base::scoped_nsobject<FakeScriptCommand> fakeScriptCommand( | 38 base::scoped_nsobject<FakeScriptCommand> fakeScriptCommand( |
| 39 [[FakeScriptCommand alloc] init]); | 39 [[FakeScriptCommand alloc] init]); |
| 40 [item1 setURL:@"invalid-url.org"]; | 40 [item1 setURL:@"invalid-url.org"]; |
| 41 EXPECT_EQ((int)AppleScript::errInvalidURL, | 41 EXPECT_EQ((int)AppleScript::errInvalidURL, |
| 42 [fakeScriptCommand.get() scriptErrorNumber]); | 42 [fakeScriptCommand.get() scriptErrorNumber]); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| OLD | NEW |