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

Side by Side Diff: chrome/browser/geolocation/geolocation_browsertest.cc

Issue 1411653004: Remove last usage functions from HostContentSettingsMap Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-host-content-settings
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include <string> 5 #include <string>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT)); 721 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
722 WatchPositionAndObservePermissionBubble(true); 722 WatchPositionAndObservePermissionBubble(true);
723 723
724 // TODO(mvanouwerkerk): Can't close a window you did not open. Maybe this was 724 // TODO(mvanouwerkerk): Can't close a window you did not open. Maybe this was
725 // valid when the test was written, but now it just prints "Scripts may close 725 // valid when the test was written, but now it just prints "Scripts may close
726 // only the windows that were opened by it." 726 // only the windows that were opened by it."
727 std::string script = "window.domAutomationController.send(window.close())"; 727 std::string script = "window.domAutomationController.send(window.close())";
728 ASSERT_TRUE(content::ExecuteScript( 728 ASSERT_TRUE(content::ExecuteScript(
729 current_browser()->tab_strip_model()->GetActiveWebContents(), script)); 729 current_browser()->tab_strip_model()->GetActiveWebContents(), script));
730 } 730 }
731
732 #if defined(OS_LINUX)
733 // http://crbug.com/527437
734 #define MAYBE_LastUsageUpdated DISABLED_LastUsageUpdated
735 #else
736 #define MAYBE_LastUsageUpdated LastUsageUpdated
737 #endif
738 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_LastUsageUpdated) {
739 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
740 base::SimpleTestClock* clock_ = new base::SimpleTestClock();
741 GetHostContentSettingsMap()->SetPrefClockForTesting(
742 scoped_ptr<base::Clock>(clock_));
743 clock_->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10));
744
745 // Setting the permission should trigger the last usage.
746 GetHostContentSettingsMap()->SetContentSetting(
747 ContentSettingsPattern::FromURLNoWildcard(current_url()),
748 ContentSettingsPattern::FromURLNoWildcard(current_url()),
749 CONTENT_SETTINGS_TYPE_GEOLOCATION,
750 std::string(),
751 CONTENT_SETTING_ALLOW);
752
753 // Permission has been used at the starting time.
754 EXPECT_EQ(GetHostContentSettingsMap()->GetLastUsage(
755 current_url().GetOrigin(),
756 current_url().GetOrigin(),
757 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 10);
758
759 clock_->Advance(base::TimeDelta::FromSeconds(3));
760
761 // Calling watchPosition should trigger the last usage update.
762 WatchPositionAndObservePermissionBubble(false);
763 ExpectPosition(fake_latitude(), fake_longitude());
764
765 // Last usage has been updated.
766 EXPECT_EQ(GetHostContentSettingsMap()->GetLastUsage(
767 current_url().GetOrigin(),
768 current_url().GetOrigin(),
769 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 13);
770 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698