[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / applescript / bookmark_item_applescript_unittest.mm
blob07c5a1f9550ee6b34bd916bf13af599041d1fc9a
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
3 // found in the LICENSE file.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/sys_string_conversions.h"
9 #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest.h"
10 #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h"
11 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #import "testing/gtest_mac.h"
14 #include "testing/platform_test.h"
15 #include "url/gurl.h"
17 typedef BookmarkAppleScriptTest BookmarkItemAppleScriptTest;
19 namespace {
21 // Set and get title.
22 TEST_F(BookmarkItemAppleScriptTest, GetAndSetTitle) {
23   NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems];
24   BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0];
25   [item1 setTitle:@"Foo"];
26   EXPECT_NSEQ(@"Foo", [item1 title]);
29 // Set and get URL.
30 TEST_F(BookmarkItemAppleScriptTest, GetAndSetURL) {
31   NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems];
32   BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0];
33   [item1 setURL:@"http://foo-bar.org"];
34   EXPECT_EQ(GURL("http://foo-bar.org"),
35             GURL(base::SysNSStringToUTF8([item1 URL])));
37   // If scripter enters invalid URL.
38   base::scoped_nsobject<FakeScriptCommand> fakeScriptCommand(
39       [[FakeScriptCommand alloc] init]);
40   [item1 setURL:@"invalid-url.org"];
41   EXPECT_EQ((int)AppleScript::errInvalidURL,
42             [fakeScriptCommand.get() scriptErrorNumber]);
45 }  // namespace