summaryrefslogtreecommitdiff
path: root/chrome/test
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2013-08-06 11:01:04 +0100
committerBen Murdoch <benm@google.com>2013-08-06 11:01:04 +0100
commit2385ea399aae016c0806a4f9ef3c9cfe3d2a39df (patch)
treee910e76d19265ff3230c473da95410d3f3a007af /chrome/test
parent8ee924b76946696c0f52e56d28cc5ab741919041 (diff)
downloadchromium_org-2385ea399aae016c0806a4f9ef3c9cfe3d2a39df.tar.gz
Merge from Chromium at DEPS revision r215849
This commit was generated by merge_to_master.py. Change-Id: I225a31651af894e33bdd71e7121702bcbe5310f4
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/base/chrome_test_launcher.cc14
-rw-r--r--chrome/test/base/testing_profile.cc8
-rw-r--r--chrome/test/base/testing_profile_manager.cc6
-rw-r--r--chrome/test/base/testing_profile_manager.h4
-rw-r--r--chrome/test/chromedriver/chrome/version.cc2
-rw-r--r--chrome/test/chromedriver/test_expectations4
-rw-r--r--chrome/test/functional/ispy/image_tools_test.py189
-rw-r--r--chrome/test/functional/ispy/ispy_core/tools/image_tools.py (renamed from chrome/test/functional/ispy/image_tools.py)105
-rw-r--r--chrome/test/functional/ispy/ispy_core/tools/image_tools_unittest.py217
-rw-r--r--chrome/test/gpu/test_support_gpu.gypi1
-rw-r--r--chrome/test/ppapi/ppapi_browsertest.cc1
11 files changed, 340 insertions, 211 deletions
diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc
index 4942a63f68..442e344a0f 100644
--- a/chrome/test/base/chrome_test_launcher.cc
+++ b/chrome/test/base/chrome_test_launcher.cc
@@ -7,6 +7,7 @@
#include <stack>
#include "base/command_line.h"
+#include "base/debug/leak_annotations.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
@@ -47,6 +48,10 @@
#include "ash/test/ui_controls_factory_ash.h"
#endif
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+#include "chrome/app/chrome_breakpad_client.h"
+#endif
+
class ChromeTestLauncherDelegate : public content::TestLauncherDelegate {
public:
ChromeTestLauncherDelegate() {}
@@ -151,6 +156,15 @@ int main(int argc, char** argv) {
#endif
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+ // We leak this pointer intentionally. The breakpad client needs to outlive
+ // all other code.
+ chrome::ChromeBreakpadClient* breakpad_client =
+ new chrome::ChromeBreakpadClient();
+ ANNOTATE_LEAKING_OBJECT_PTR(breakpad_client);
+ breakpad::SetBreakpadClient(breakpad_client);
+#endif
+
ChromeTestLauncherDelegate launcher_delegate;
return content::LaunchTests(&launcher_delegate, argc, argv);
}
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 3d9511da7f..9570da03e3 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -283,6 +283,11 @@ void TestingProfile::CreateTempProfileDir() {
}
void TestingProfile::Init() {
+ // If threads have been initialized, we should be on the UI thread.
+ DCHECK(
+ !content::BrowserThread::IsWellKnownThread(content::BrowserThread::UI) ||
+ content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
// Normally this would happen during browser startup, but for tests
// we need to trigger creation of Profile-related services.
ChromeBrowserMainExtraPartsProfiles::
@@ -547,7 +552,8 @@ Profile* TestingProfile::GetOriginalProfile() {
}
bool TestingProfile::IsManaged() {
- return GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+ return GetPrefs()->GetBoolean(prefs::kProfileIsManaged) ||
+ !GetPrefs()->GetString(prefs::kManagedUserId).empty();
}
ExtensionService* TestingProfile::GetExtensionService() {
diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc
index b0c6604d51..e6f4748a30 100644
--- a/chrome/test/base/testing_profile_manager.cc
+++ b/chrome/test/base/testing_profile_manager.cc
@@ -49,7 +49,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
scoped_ptr<PrefServiceSyncable> prefs,
const string16& user_name,
int avatar_id,
- bool is_managed) {
+ const std::string& managed_user_id) {
DCHECK(called_set_up_);
// Create a path for the profile based on the name.
@@ -68,7 +68,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(profile_path);
cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
- cache.SetProfileIsManagedAtIndex(index, is_managed);
+ cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id);
// SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
// last.
cache.SetNameOfProfileAtIndex(index, user_name);
@@ -82,7 +82,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
const std::string& name) {
DCHECK(called_set_up_);
return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(),
- UTF8ToUTF16(name), 0, false);
+ UTF8ToUTF16(name), 0, std::string());
}
void TestingProfileManager::DeleteTestingProfile(const std::string& name) {
diff --git a/chrome/test/base/testing_profile_manager.h b/chrome/test/base/testing_profile_manager.h
index 0e27dce133..01f331760e 100644
--- a/chrome/test/base/testing_profile_manager.h
+++ b/chrome/test/base/testing_profile_manager.h
@@ -43,7 +43,7 @@ class TestingProfileManager {
// profile_name, which is a non-user-visible key for the test environment.
// |prefs| is the PrefService used by the profile. If it is NULL, the profile
// creates a PrefService on demand.
- // |user_name|, |avatar_id| and |is_managed| are passed along to the
+ // |user_name|, |avatar_id| and |managed_user_id| are passed along to the
// ProfileInfoCache and provide the user-visible profile metadata. This will
// register the TestingProfile with the profile subsystem as well. The
// subsystem owns the Profile and returns a weak pointer.
@@ -51,7 +51,7 @@ class TestingProfileManager {
scoped_ptr<PrefServiceSyncable> prefs,
const string16& user_name,
int avatar_id,
- bool is_managed);
+ const std::string& managed_user_id);
// Small helper for creating testing profiles. Just forwards to above.
TestingProfile* CreateTestingProfile(const std::string& name);
diff --git a/chrome/test/chromedriver/chrome/version.cc b/chrome/test/chromedriver/chrome/version.cc
index ed7e1e0ad3..5044936d9b 100644
--- a/chrome/test/chromedriver/chrome/version.cc
+++ b/chrome/test/chromedriver/chrome/version.cc
@@ -14,7 +14,7 @@ const int kMinimumSupportedChromeVersion[] = {27, 0, 1453, 0};
} // namespace
// This variable must be able to be found and parsed by the upload script.
-const char kChromeDriverVersion[] = "2.1";
+const char kChromeDriverVersion[] = "2.2";
const int kMinimumSupportedChromeBuildNo = kMinimumSupportedChromeVersion[2];
diff --git a/chrome/test/chromedriver/test_expectations b/chrome/test/chromedriver/test_expectations
index 6595296305..1e17ea2f34 100644
--- a/chrome/test/chromedriver/test_expectations
+++ b/chrome/test/chromedriver/test_expectations
@@ -113,6 +113,7 @@ _OS_NEGATIVE_FILTER['win'] = [
'RenderedWebElementTest.canClickOnASuckerFishStyleMenu',
# Flaky: https://code.google.com/p/chromedriver/issues/detail?id=416
'TakesScreenshotTest.testShouldCaptureScreenshotAtIFramePageAfterSwitching',
+ 'TakesScreenshotTest.testShouldCaptureScreenshotAtFramePage',
]
_OS_NEGATIVE_FILTER['linux'] = []
_OS_NEGATIVE_FILTER['mac'] = [
@@ -175,6 +176,9 @@ _OS_NEGATIVE_FILTER['android'] = [
'UploadTest.testFileUploading',
# Not applicable on Chromium Test Shell (doesn't support tabs).
'WindowSwitchingTest.*',
+
+ # Flaky: https://code.google.com/p/chromedriver/issues/detail?id=441
+ 'PageLoadingTest.testShouldBeAbleToNavigateBackInTheBrowserHistory',
]
diff --git a/chrome/test/functional/ispy/image_tools_test.py b/chrome/test/functional/ispy/image_tools_test.py
deleted file mode 100644
index 4ae5793faf..0000000000
--- a/chrome/test/functional/ispy/image_tools_test.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import unittest
-from PIL import Image
-
-import image_tools
-
-
-def _GenImage(size, color):
- return Image.new('RGB', size, color)
-
-
-def _AllPixelsOfColor(image, color):
- return not any(px != color for px in image.getdata())
-
-
-class ImageToolsTest(unittest.TestCase):
-
- def testAreTheSameSize(self):
- black25x25 = _GenImage((25, 25), (0, 0, 0))
- white25x25 = _GenImage((25, 25), (255, 255, 255))
- black50x50 = _GenImage((50, 50), (0, 0, 0))
- white50x50 = _GenImage((50, 50), (255, 255, 255))
-
- self.assertTrue(image_tools._AreTheSameSize([black25x25, black25x25]))
- self.assertTrue(image_tools._AreTheSameSize([white25x25, white25x25]))
- self.assertTrue(image_tools._AreTheSameSize([black50x50, black50x50]))
- self.assertTrue(image_tools._AreTheSameSize([white50x50, white50x50]))
- self.assertTrue(image_tools._AreTheSameSize([black25x25, white25x25]))
- self.assertTrue(image_tools._AreTheSameSize([black50x50, white50x50]))
-
- self.assertFalse(image_tools._AreTheSameSize([black50x50, black25x25]))
- self.assertFalse(image_tools._AreTheSameSize([white50x50, white25x25]))
- self.assertFalse(image_tools._AreTheSameSize([black25x25, white50x50]))
- self.assertFalse(image_tools._AreTheSameSize([black50x50, white25x25]))
-
- self.assertRaises(Exception, image_tools._AreTheSameSize, [])
- self.assertRaises(Exception, image_tools._AreTheSameSize, [black50x50])
-
- def testGetDifferenceWithMask(self):
- black25x25 = _GenImage((25, 25), (0, 0, 0))
- white25x25 = _GenImage((25, 25), (255, 255, 255))
- black50x50 = _GenImage((50, 50), (0, 0, 0))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- black25x25, black25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- white25x25, white25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- white25x25, black25x25), (255, 255, 255)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- black25x25, black25x25, mask=black25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- black25x25, black25x25, mask=white25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- black25x25, white25x25, mask=black25x25), (255, 255, 255)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- black25x25, white25x25, mask=white25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- black25x25, white25x25, different_color=(255, 0, 0)), (255, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- white25x25, white25x25, same_color=(255, 0, 0)), (255, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
- white25x25, white25x25,
- mask=white25x25, masked_color=(255, 0, 0)), (255, 0, 0)))
- self.assertRaises(Exception, image_tools._GetDifferenceWithMask,
- white25x25,
- black50x50)
- self.assertRaises(Exception, image_tools._GetDifferenceWithMask,
- white25x25,
- white25x25,
- mask=black50x50)
-
- def testCreateMask(self):
- black25x25 = _GenImage((25, 25), (0, 0, 0))
- white25x25 = _GenImage((25, 25), (255, 255, 255))
-
- m1 = image_tools.CreateMask([black25x25, white25x25])
- self.assertTrue(_AllPixelsOfColor(m1, (255, 255, 255)))
- m2 = image_tools.CreateMask([black25x25, black25x25])
- self.assertTrue(_AllPixelsOfColor(m2, (0, 0, 0)))
- m3 = image_tools.CreateMask([white25x25, white25x25])
- self.assertTrue(_AllPixelsOfColor(m3, (0, 0, 0)))
-
- def testTotalDifferentPixels(self):
- white25x25 = _GenImage((25, 25), (255, 255, 255))
- white50x50 = _GenImage((50, 50), (255, 255, 255))
- black25x25 = _GenImage((25, 25), (0, 0, 0))
-
- self.assertEquals(image_tools.TotalDifferentPixels(white25x25,
- white25x25),
- 0)
- self.assertEquals(image_tools.TotalDifferentPixels(black25x25,
- black25x25),
- 0)
- self.assertEquals(image_tools.TotalDifferentPixels(white25x25,
- black25x25),
- 25*25)
- self.assertEquals(image_tools.TotalDifferentPixels(white25x25,
- black25x25,
- mask=white25x25),
- 0)
- self.assertEquals(image_tools.TotalDifferentPixels(white25x25,
- white25x25,
- mask=white25x25),
- 0)
- self.assertEquals(image_tools.TotalDifferentPixels(white25x25,
- black25x25,
- mask=black25x25),
- 25*25)
- self.assertEquals(image_tools.TotalDifferentPixels(white25x25,
- white25x25,
- mask=black25x25),
- 0)
- self.assertRaises(Exception, image_tools.TotalDifferentPixels,
- white25x25, white50x50)
- self.assertRaises(Exception, image_tools.TotalDifferentPixels,
- white25x25, white25x25, mask=white50x50)
-
- def testSameImage(self):
- white25x25 = _GenImage((25, 25), (255, 255, 255))
- black25x25 = _GenImage((25, 25), (0, 0, 0))
- white50x50 = _GenImage((50, 50), (255, 255, 255))
-
- self.assertTrue(image_tools.SameImage(white25x25, white25x25))
- self.assertFalse(image_tools.SameImage(white25x25, black25x25))
-
- self.assertTrue(image_tools.SameImage(white25x25, black25x25,
- mask=white25x25))
- self.assertFalse(image_tools.SameImage(white25x25, black25x25,
- mask=black25x25))
- self.assertTrue(image_tools.SameImage(black25x25, black25x25))
- self.assertTrue(image_tools.SameImage(black25x25, black25x25,
- mask=white25x25))
- self.assertTrue(image_tools.SameImage(white25x25, white25x25,
- mask=white25x25))
- self.assertRaises(Exception, image_tools.SameImage,
- white25x25, white50x50)
- self.assertRaises(Exception, image_tools.SameImage,
- white25x25, white25x25,
- mask=white50x50)
-
- def testVisualizeImageDifferences(self):
- white25x25 = _GenImage((25, 25), (255, 255, 255))
- black25x25 = _GenImage((25, 25), (0, 0, 0))
- white50x50 = _GenImage((50, 50), (255, 255, 255))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- white25x25, black25x25), (255, 255, 255)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- white25x25, white25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- black25x25, black25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- white25x25, black25x25, mask=white25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- white25x25, black25x25, mask=black25x25), (255, 255, 255)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- white25x25, white25x25, mask=white25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- white25x25, white25x25, mask=black25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- black25x25, black25x25, mask=black25x25), (0, 0, 0)))
- self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
- black25x25, black25x25, mask=white25x25), (0, 0, 0)))
-
- self.assertRaises(Exception,
- image_tools.VisualizeImageDifferences,
- white25x25,
- white50x50)
- self.assertRaises(Exception,
- image_tools.VisualizeImageDifferences,
- white25x25,
- black25x25,
- mask=white50x50)
-
- def testSerialization(self):
- black25x25 = _GenImage((25, 25), (0, 0, 0))
- white25x25 = _GenImage((25, 25), (255, 255, 255))
- self.assertTrue(_AllPixelsOfColor(
- image_tools.DeserializeImage(
- image_tools.SerializeImage(white25x25)), (255, 255, 255)))
- self.assertTrue(_AllPixelsOfColor(
- image_tools.DeserializeImage(
- image_tools.SerializeImage(black25x25)), (0, 0, 0)))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/chrome/test/functional/ispy/image_tools.py b/chrome/test/functional/ispy/ispy_core/tools/image_tools.py
index bf0402ad95..e87dbe817b 100644
--- a/chrome/test/functional/ispy/image_tools.py
+++ b/chrome/test/functional/ispy/ispy_core/tools/image_tools.py
@@ -6,7 +6,6 @@
import itertools
import StringIO
-import PIL
from PIL import Image
@@ -29,9 +28,9 @@ def _AreTheSameSize(images):
def _GetDifferenceWithMask(image1, image2, mask=None,
- masked_color=(0, 0, 0),
- same_color=(0, 0, 0),
- different_color=(255, 255, 255)):
+ masked_color=(0, 0, 0, 255),
+ same_color=(0, 0, 0, 255),
+ different_color=(255, 255, 255, 255)):
"""Returns an image representing the difference between the two images.
This function computes the difference between two images taking into
@@ -57,15 +56,15 @@ def _GetDifferenceWithMask(image1, image2, mask=None,
"""
image_mask = mask
if not mask:
- image_mask = PIL.Image.new('RGB', image1.size, (0, 0, 0))
+ image_mask = Image.new('RGBA', image1.size, (0, 0, 0, 255))
if not _AreTheSameSize([image1, image2, image_mask]):
raise Exception('images and mask must be the same size.')
- image_diff = PIL.Image.new('RGB', image1.size, (0, 0, 0))
+ image_diff = Image.new('RGBA', image1.size, (0, 0, 0, 255))
data = []
for m, px1, px2 in itertools.izip(image_mask.getdata(),
image1.getdata(),
image2.getdata()):
- if m == (255, 255, 255):
+ if m == (255, 255, 255, 255):
data.append(masked_color)
elif px1 == px2:
data.append(same_color)
@@ -97,17 +96,43 @@ def CreateMask(images):
"""
if len(images) < 2:
raise Exception('mask must be created from two or more images.')
- mask = Image.new('RGB', images[0].size, (0, 0, 0))
+ mask = Image.new('RGBA', images[0].size, (0, 0, 0, 255))
image = images[0]
for other_image in images[1:]:
mask = _GetDifferenceWithMask(
image,
other_image,
mask,
- masked_color=(255, 255, 255))
+ masked_color=(255, 255, 255, 255))
return mask
+def AddMasks(masks):
+ """Combines a list of mask images into one mask image.
+
+ Args:
+ masks: a list of mask-images.
+
+ Returns:
+ a new mask that represents the sum of the masked
+ regions of the passed in list of mask-images.
+
+ Raises:
+ Exception: if masks is an empty list, or if masks are not the same size.
+ """
+ if not masks:
+ raise Exception('masks must be a list containing at least one image.')
+ if len(masks) > 1 and not _AreTheSameSize(masks):
+ raise Exception('masks in list must be of the same size.')
+ white = (255, 255, 255, 255)
+ black = (0, 0, 0, 255)
+ masks_data = [mask.getdata() for mask in masks]
+ image = Image.new('RGBA', masks[0].size, black)
+ image.putdata([white if white in px_set else black
+ for px_set in itertools.izip(*masks_data)])
+ return image
+
+
def VisualizeImageDifferences(image1, image2, mask=None):
"""Returns an image repesenting the unmasked differences between two images.
@@ -134,6 +159,60 @@ def VisualizeImageDifferences(image1, image2, mask=None):
return _GetDifferenceWithMask(image1, image2, mask)
+def InflateMask(image, passes):
+ """A function that adds layers of pixels around the white edges of a mask.
+
+ This function evaluates a 'frontier' of valid pixels indices. Initially,
+ this frontier contains all indices in the image. However, with each pass
+ only the pixels' indices which were added to the mask by inflation
+ are added to the next pass's frontier. This gives the algorithm a
+ large upfront cost that scales negligably when the number of passes
+ is increased.
+
+ Args:
+ image: the RGBA PIL.Image mask to inflate.
+ passes: the number of passes to inflate the image by.
+
+ Returns:
+ A RGBA PIL.Image.
+ """
+ inflated = Image.new('RGBA', image.size)
+ new_dataset = list(image.getdata())
+ old_dataset = list(image.getdata())
+
+ frontier = set(range(len(old_dataset)))
+ new_frontier = set()
+
+ l = [-1, 1]
+
+ def _ShadeHorizontal(index, px):
+ col = index % image.size[0]
+ if px == (255, 255, 255, 255):
+ for x in l:
+ if 0 <= col + x < image.size[0]:
+ if old_dataset[index + x] != (255, 255, 255, 255):
+ new_frontier.add(index + x)
+ new_dataset[index + x] = (255, 255, 255, 255)
+
+ def _ShadeVertical(index, px):
+ row = index / image.size[0]
+ if px == (255, 255, 255, 255):
+ for x in l:
+ if 0 <= row + x < image.size[1]:
+ if old_dataset[index + image.size[0] * x] != (255, 255, 255, 255):
+ new_frontier.add(index + image.size[0] * x)
+ new_dataset[index + image.size[0] * x] = (255, 255, 255, 255)
+
+ for _ in range(passes):
+ for index in frontier:
+ _ShadeHorizontal(index, old_dataset[index])
+ _ShadeVertical(index, old_dataset[index])
+ old_dataset, new_dataset = new_dataset, new_dataset
+ frontier, new_frontier = new_frontier, set()
+ inflated.putdata(new_dataset)
+ return inflated
+
+
def TotalDifferentPixels(image1, image2, mask=None):
"""Computes the number of different pixels between two images.
@@ -151,13 +230,13 @@ def TotalDifferentPixels(image1, image2, mask=None):
"""
image_mask = mask
if not mask:
- image_mask = PIL.Image.new('RGB', image1.size, (0, 0, 0))
+ image_mask = Image.new('RGBA', image1.size, (0, 0, 0, 255))
if _AreTheSameSize([image1, image2, image_mask]):
total_diff = 0
for px1, px2, m in itertools.izip(image1.getdata(),
image2.getdata(),
image_mask.getdata()):
- if m == (255, 255, 255):
+ if m == (255, 255, 255, 255):
continue
elif px1 != px2:
total_diff += 1
@@ -217,6 +296,4 @@ def DeserializeImage(encoded_image):
Returns:
an RGB image
"""
- return PIL.Image.open(StringIO.StringIO(encoded_image.decode('base64')))
-
-
+ return Image.open(StringIO.StringIO(encoded_image.decode('base64')))
diff --git a/chrome/test/functional/ispy/ispy_core/tools/image_tools_unittest.py b/chrome/test/functional/ispy/ispy_core/tools/image_tools_unittest.py
new file mode 100644
index 0000000000..46f3702a8f
--- /dev/null
+++ b/chrome/test/functional/ispy/ispy_core/tools/image_tools_unittest.py
@@ -0,0 +1,217 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+from PIL import Image
+import image_tools
+
+
+def _GenImage(size, color):
+ return Image.new('RGBA', size, color)
+
+
+def _AllPixelsOfColor(image, color):
+ return not any(px != color for px in image.getdata())
+
+
+class ImageToolsTest(unittest.TestCase):
+
+ def setUp(self):
+ self.black25 = _GenImage((25, 25), (0, 0, 0, 255))
+ self.black50 = _GenImage((50, 50), (0, 0, 0, 255))
+ self.white25 = _GenImage((25, 25), (255, 255, 255, 255))
+ self.white50 = _GenImage((50, 50), (255, 255, 255, 255))
+
+ def testAreTheSameSize(self):
+ self.assertTrue(image_tools._AreTheSameSize([self.black25, self.black25]))
+ self.assertTrue(image_tools._AreTheSameSize([self.white25, self.white25]))
+ self.assertTrue(image_tools._AreTheSameSize([self.black50, self.black50]))
+ self.assertTrue(image_tools._AreTheSameSize([self.white50, self.white50]))
+ self.assertTrue(image_tools._AreTheSameSize([self.black25, self.white25]))
+ self.assertTrue(image_tools._AreTheSameSize([self.black50, self.white50]))
+
+ self.assertFalse(image_tools._AreTheSameSize([self.black50, self.black25]))
+ self.assertFalse(image_tools._AreTheSameSize([self.white50, self.white25]))
+ self.assertFalse(image_tools._AreTheSameSize([self.black25, self.white50]))
+ self.assertFalse(image_tools._AreTheSameSize([self.black50, self.white25]))
+
+ self.assertRaises(Exception, image_tools._AreTheSameSize, [])
+ self.assertRaises(Exception, image_tools._AreTheSameSize, [self.black50])
+
+ def testGetDifferenceWithMask(self):
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.black25, self.black25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.white25, self.white25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.white25, self.black25), (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.black25, self.black25, mask=self.black25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.black25, self.black25, mask=self.white25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.black25, self.white25, mask=self.black25), (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.black25, self.white25, mask=self.white25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.black25, self.white25, different_color=(255, 0, 0, 255)),
+ (255, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.white25, self.white25, same_color=(255, 0, 0, 255)),
+ (255, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask(
+ self.white25, self.white25,
+ mask=self.white25, masked_color=(255, 0, 0, 255)), (255, 0, 0, 255)))
+ self.assertRaises(Exception, image_tools._GetDifferenceWithMask,
+ self.white25,
+ self.black50)
+ self.assertRaises(Exception, image_tools._GetDifferenceWithMask,
+ self.white25,
+ self.white25,
+ mask=self.black50)
+
+ def testCreateMask(self):
+ m1 = image_tools.CreateMask([self.black25, self.white25])
+ self.assertTrue(_AllPixelsOfColor(m1, (255, 255, 255, 255)))
+ m2 = image_tools.CreateMask([self.black25, self.black25])
+ self.assertTrue(_AllPixelsOfColor(m2, (0, 0, 0, 255)))
+ m3 = image_tools.CreateMask([self.white25, self.white25])
+ self.assertTrue(_AllPixelsOfColor(m3, (0, 0, 0, 255)))
+
+ def testAddMasks(self):
+ m1 = image_tools.CreateMask([self.black25, self.white25])
+ m2 = image_tools.CreateMask([self.black25, self.black25])
+ m3 = image_tools.CreateMask([self.black50, self.black50])
+ self.assertTrue(_AllPixelsOfColor(image_tools.AddMasks([m1]),
+ (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.AddMasks([m2]),
+ (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.AddMasks([m1, m2]),
+ (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.AddMasks([m1, m1]),
+ (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.AddMasks([m2, m2]),
+ (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.AddMasks([m3]),
+ (0, 0, 0, 255)))
+ self.assertRaises(Exception, image_tools.AddMasks, [])
+ self.assertRaises(Exception, image_tools.AddMasks, [m1, m3])
+
+ def testTotalDifferentPixels(self):
+ self.assertEquals(image_tools.TotalDifferentPixels(self.white25,
+ self.white25),
+ 0)
+ self.assertEquals(image_tools.TotalDifferentPixels(self.black25,
+ self.black25),
+ 0)
+ self.assertEquals(image_tools.TotalDifferentPixels(self.white25,
+ self.black25),
+ 25*25)
+ self.assertEquals(image_tools.TotalDifferentPixels(self.white25,
+ self.black25,
+ mask=self.white25),
+ 0)
+ self.assertEquals(image_tools.TotalDifferentPixels(self.white25,
+ self.white25,
+ mask=self.white25),
+ 0)
+ self.assertEquals(image_tools.TotalDifferentPixels(self.white25,
+ self.black25,
+ mask=self.black25),
+ 25*25)
+ self.assertEquals(image_tools.TotalDifferentPixels(self.white25,
+ self.white25,
+ mask=self.black25),
+ 0)
+ self.assertRaises(Exception, image_tools.TotalDifferentPixels,
+ self.white25, self.white50)
+ self.assertRaises(Exception, image_tools.TotalDifferentPixels,
+ self.white25, self.white25, mask=self.white50)
+
+ def testSameImage(self):
+ self.assertTrue(image_tools.SameImage(self.white25, self.white25))
+ self.assertFalse(image_tools.SameImage(self.white25, self.black25))
+
+ self.assertTrue(image_tools.SameImage(self.white25, self.black25,
+ mask=self.white25))
+ self.assertFalse(image_tools.SameImage(self.white25, self.black25,
+ mask=self.black25))
+ self.assertTrue(image_tools.SameImage(self.black25, self.black25))
+ self.assertTrue(image_tools.SameImage(self.black25, self.black25,
+ mask=self.white25))
+ self.assertTrue(image_tools.SameImage(self.white25, self.white25,
+ mask=self.white25))
+ self.assertRaises(Exception, image_tools.SameImage,
+ self.white25, self.white50)
+ self.assertRaises(Exception, image_tools.SameImage,
+ self.white25, self.white25,
+ mask=self.white50)
+
+ def testInflateMask(self):
+ cross_image = Image.new('RGBA', (3, 3))
+ white_image = Image.new('RGBA', (3, 3))
+ dot_image = Image.new('RGBA', (3, 3))
+ b = (0, 0, 0, 255)
+ w = (255, 255, 255, 255)
+ dot_image.putdata([b, b, b,
+ b, w, b,
+ b, b, b])
+ cross_image.putdata([b, w, b,
+ w, w, w,
+ b, w, b])
+ white_image.putdata([w, w, w,
+ w, w, w,
+ w, w, w])
+ self.assertEquals(list(image_tools.InflateMask(dot_image, 1).getdata()),
+ list(cross_image.getdata()))
+ self.assertEquals(list(image_tools.InflateMask(dot_image, 0).getdata()),
+ list(dot_image.getdata()))
+ self.assertEquals(list(image_tools.InflateMask(dot_image, 2).getdata()),
+ list(white_image.getdata()))
+ self.assertEquals(list(image_tools.InflateMask(dot_image, 3).getdata()),
+ list(white_image.getdata()))
+ self.assertEquals(list(image_tools.InflateMask(self.black25, 1).getdata()),
+ list(self.black25.getdata()))
+
+ def testVisualizeImageDifferences(self):
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.white25, self.black25), (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.white25, self.white25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.black25, self.black25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.white25, self.black25, mask=self.white25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.white25, self.black25, mask=self.black25), (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.white25, self.white25, mask=self.white25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.white25, self.white25, mask=self.black25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.black25, self.black25, mask=self.black25), (0, 0, 0, 255)))
+ self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences(
+ self.black25, self.black25, mask=self.white25), (0, 0, 0, 255)))
+
+ self.assertRaises(Exception,
+ image_tools.VisualizeImageDifferences,
+ self.white25,
+ self.white50)
+ self.assertRaises(Exception,
+ image_tools.VisualizeImageDifferences,
+ self.white25,
+ self.black25,
+ mask=self.white50)
+
+ def testSerialization(self):
+ self.assertTrue(_AllPixelsOfColor(
+ image_tools.DeserializeImage(
+ image_tools.SerializeImage(self.white25)), (255, 255, 255, 255)))
+ self.assertTrue(_AllPixelsOfColor(
+ image_tools.DeserializeImage(
+ image_tools.SerializeImage(self.black25)), (0, 0, 0, 255)))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/chrome/test/gpu/test_support_gpu.gypi b/chrome/test/gpu/test_support_gpu.gypi
index 083c0e3c8f..f2c9b57a30 100644
--- a/chrome/test/gpu/test_support_gpu.gypi
+++ b/chrome/test/gpu/test_support_gpu.gypi
@@ -104,6 +104,7 @@
'dependencies': [
'<@(chromium_browser_dependencies)',
'<@(chromium_child_dependencies)',
+ '../content/content.gyp:content_app_both',
'chrome_resources.gyp:packed_resources',
'chrome_resources.gyp:packed_extra_resources',
],
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index 8c8bdb3812..c9d15d812e 100644
--- a/chrome/test/ppapi/ppapi_browsertest.cc
+++ b/chrome/test/ppapi/ppapi_browsertest.cc
@@ -409,7 +409,6 @@ TEST_PPAPI_NACL_DISALLOWED_SOCKETS(TCPServerSocketPrivateDisallowed)
TEST_PPAPI_NACL_DISALLOWED_SOCKETS(TCPSocketPrivateDisallowed)
TEST_PPAPI_NACL_DISALLOWED_SOCKETS(UDPSocketPrivateDisallowed)
-TEST_PPAPI_IN_PROCESS_VIA_HTTP(TCPServerSocketPrivate)
TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(TCPServerSocketPrivate)
TEST_PPAPI_NACL(TCPServerSocketPrivate)