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

Side by Side Diff: chrome/browser/ui/cocoa/simple_content_exceptions_window_controller_unittest.mm

Issue 6294008: [Mac] Organize some files into chrome/browser/ui/cocoa/content_settings/.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #import "chrome/browser/ui/cocoa/simple_content_exceptions_window_controller.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #import "base/scoped_nsobject.h"
10 #include "base/ref_counted.h"
11 #include "chrome/browser/content_settings/host_content_settings_map.h"
12 #include "chrome/browser/geolocation/geolocation_exceptions_table_model.h"
13 #include "chrome/browser/plugin_exceptions_table_model.h"
14 #include "chrome/browser/ui/cocoa/browser_test_helper.h"
15 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/platform_test.h"
18
19 @interface SimpleContentExceptionsWindowController (Testing)
20
21 @property(readonly, nonatomic) TableModelArrayController* arrayController;
22
23 @end
24
25 @implementation SimpleContentExceptionsWindowController (Testing)
26
27 - (TableModelArrayController*)arrayController {
28 return arrayController_;
29 }
30
31 @end
32
33
34 namespace {
35
36 class SimpleContentExceptionsWindowControllerTest : public CocoaTest {
37 public:
38 virtual void SetUp() {
39 CocoaTest::SetUp();
40 TestingProfile* profile = browser_helper_.profile();
41 geolocation_settings_ = new GeolocationContentSettingsMap(profile);
42 content_settings_ = new HostContentSettingsMap(profile);
43 }
44
45 SimpleContentExceptionsWindowController* GetController() {
46 GeolocationExceptionsTableModel* model = // Freed by window controller.
47 new GeolocationExceptionsTableModel(geolocation_settings_.get());
48 id controller = [SimpleContentExceptionsWindowController
49 controllerWithTableModel:model];
50 [controller showWindow:nil];
51 return controller;
52 }
53
54 void ClickRemoveAll(SimpleContentExceptionsWindowController* controller) {
55 [controller.arrayController removeAll:nil];
56 }
57
58 protected:
59 BrowserTestHelper browser_helper_;
60 scoped_refptr<GeolocationContentSettingsMap> geolocation_settings_;
61 scoped_refptr<HostContentSettingsMap> content_settings_;
62 };
63
64 TEST_F(SimpleContentExceptionsWindowControllerTest, Construction) {
65 GeolocationExceptionsTableModel* model = // Freed by window controller.
66 new GeolocationExceptionsTableModel(geolocation_settings_.get());
67 SimpleContentExceptionsWindowController* controller =
68 [SimpleContentExceptionsWindowController controllerWithTableModel:model];
69 [controller showWindow:nil];
70 [controller close]; // Should autorelease.
71 }
72
73 TEST_F(SimpleContentExceptionsWindowControllerTest, ShowPluginExceptions) {
74 PluginExceptionsTableModel* model = // Freed by window controller.
75 new PluginExceptionsTableModel(content_settings_.get(), NULL);
76 SimpleContentExceptionsWindowController* controller =
77 [SimpleContentExceptionsWindowController controllerWithTableModel:model];
78 [controller showWindow:nil];
79 [controller close]; // Should autorelease.
80 }
81
82 TEST_F(SimpleContentExceptionsWindowControllerTest, AddExistingEditAdd) {
83 geolocation_settings_->SetContentSetting(
84 GURL("http://myhost"), GURL(), CONTENT_SETTING_BLOCK);
85
86 SimpleContentExceptionsWindowController* controller = GetController();
87 ClickRemoveAll(controller);
88
89 [controller close];
90
91 EXPECT_EQ(0u, geolocation_settings_->GetAllOriginsSettings().size());
92 }
93
94 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698